本文整理汇总了Python中celery.app.trace.TraceInfo类的典型用法代码示例。如果您正苦于以下问题:Python TraceInfo类的具体用法?Python TraceInfo怎么用?Python TraceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TraceInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_worker_task_trace_handle_failure
def test_worker_task_trace_handle_failure(self):
tid = uuid()
self.mytask.push_request()
try:
self.mytask.request.id = tid
try:
raise ValueError("foo")
except Exception as exc:
w = TraceInfo(states.FAILURE, exc)
w.handle_failure(self.mytask, store_errors=False)
self.assertEqual(self.mytask.backend.get_status(tid), states.PENDING)
w.handle_failure(self.mytask, store_errors=True)
self.assertEqual(self.mytask.backend.get_status(tid), states.FAILURE)
finally:
self.mytask.pop_request()
示例2: test_worker_task_trace_handle_retry
def test_worker_task_trace_handle_retry(self):
tid = uuid()
self.mytask.push_request(id=tid)
try:
raise ValueError("foo")
except Exception as exc:
try:
raise Retry(str(exc), exc=exc)
except Retry as exc:
w = TraceInfo(states.RETRY, exc)
w.handle_retry(self.mytask, store_errors=False)
self.assertEqual(self.mytask.backend.get_status(tid), states.PENDING)
w.handle_retry(self.mytask, store_errors=True)
self.assertEqual(self.mytask.backend.get_status(tid), states.RETRY)
finally:
self.mytask.pop_request()
示例3: test_worker_task_trace_handle_retry
def test_worker_task_trace_handle_retry(self):
from celery.exceptions import RetryTaskError
tid = uuid()
mytask.push_request(id=tid)
try:
raise ValueError('foo')
except Exception as exc:
try:
raise RetryTaskError(str(exc), exc=exc)
except RetryTaskError as exc:
w = TraceInfo(states.RETRY, exc)
w.handle_retry(mytask, store_errors=False)
self.assertEqual(mytask.backend.get_status(tid),
states.PENDING)
w.handle_retry(mytask, store_errors=True)
self.assertEqual(mytask.backend.get_status(tid),
states.RETRY)
finally:
mytask.pop_request()