本文整理匯總了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()