本文整理汇总了Python中billiard.einfo.ExceptionInfo类的典型用法代码示例。如果您正苦于以下问题:Python ExceptionInfo类的具体用法?Python ExceptionInfo怎么用?Python ExceptionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExceptionInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_failure
def handle_failure(self, task, req, store_errors=True, call_errbacks=True):
"""Handle exception."""
_, _, tb = sys.exc_info()
try:
exc = self.retval
# make sure we only send pickleable exceptions back to parent.
einfo = ExceptionInfo()
einfo.exception = get_pickleable_exception(einfo.exception)
einfo.type = get_pickleable_etype(einfo.type)
task.backend.mark_as_failure(
req.id, exc, einfo.traceback,
request=req, store_result=store_errors,
call_errbacks=call_errbacks,
)
task.on_failure(exc, req.id, req.args, req.kwargs, einfo)
signals.task_failure.send(sender=task, task_id=req.id,
exception=exc, args=req.args,
kwargs=req.kwargs,
traceback=tb,
einfo=einfo)
self._log_error(task, req, einfo)
return einfo
finally:
del(tb)
示例2: test_on_retry
def test_on_retry(self):
job = self.get_request(self.mytask.s(1, f='x'))
job.eventer = MockEventDispatcher()
try:
raise Retry('foo', KeyError('moofoobar'))
except:
einfo = ExceptionInfo()
job.on_failure(einfo)
self.assertIn('task-retried', job.eventer.sent)
prev, module._does_info = module._does_info, False
try:
job.on_failure(einfo)
finally:
module._does_info = prev
einfo.internal = True
job.on_failure(einfo)
示例3: test_on_retry
def test_on_retry(self):
job = Request({"task": self.mytask.name, "id": uuid(), "args": [1], "kwargs": {"f": "x"}}, app=self.app)
job.eventer = MockEventDispatcher()
try:
raise Retry("foo", KeyError("moofoobar"))
except:
einfo = ExceptionInfo()
job.on_failure(einfo)
self.assertIn("task-retried", job.eventer.sent)
prev, module._does_info = module._does_info, False
try:
job.on_failure(einfo)
finally:
module._does_info = prev
einfo.internal = True
job.on_failure(einfo)
示例4: test_on_retry
def test_on_retry(self):
tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'})
tw.eventer = MockEventDispatcher()
try:
raise RetryTaskError('foo', KeyError('moofoobar'))
except:
einfo = ExceptionInfo()
tw.on_failure(einfo)
self.assertIn('task-retried', tw.eventer.sent)
prev, module._does_info = module._does_info, False
try:
tw.on_failure(einfo)
finally:
module._does_info = prev
einfo.internal = True
tw.on_failure(einfo)
示例5: handle_failure
def handle_failure(self, task, store_errors=True):
"""Handle exception."""
req = task.request
type_, _, tb = sys.exc_info()
try:
exc = self.retval
einfo = ExceptionInfo()
einfo.exception = get_pickleable_exception(einfo.exception)
einfo.type = get_pickleable_etype(einfo.type)
if store_errors:
task.backend.mark_as_failure(req.id, exc, einfo.traceback, request=req)
task.on_failure(exc, req.id, req.args, req.kwargs, einfo)
signals.task_failure.send(
sender=task, task_id=req.id, exception=exc, args=req.args, kwargs=req.kwargs, traceback=tb, einfo=einfo
)
return einfo
finally:
del (tb)
示例6: test_on_retry
def test_on_retry(self):
job = self.get_request(self.mytask.s(1, f='x'))
job.eventer = Mock(name='.eventer')
try:
raise Retry('foo', KeyError('moofoobar'))
except:
einfo = ExceptionInfo()
job.on_failure(einfo)
job.eventer.send.assert_called_with(
'task-retried',
uuid=job.id,
exception=safe_repr(einfo.exception.exc),
traceback=safe_str(einfo.traceback),
)
prev, module._does_info = module._does_info, False
try:
job.on_failure(einfo)
finally:
module._does_info = prev
einfo.internal = True
job.on_failure(einfo)
示例7: test_on_retry
def test_on_retry(self):
job = Request({
'task': self.mytask.name,
'id': uuid(),
'args': [1],
'kwargs': {'f': 'x'},
}, app=self.app)
job.eventer = MockEventDispatcher()
try:
raise Retry('foo', KeyError('moofoobar'))
except:
einfo = ExceptionInfo()
job.on_failure(einfo)
self.assertIn('task-retried', job.eventer.sent)
prev, module._does_info = module._does_info, False
try:
job.on_failure(einfo)
finally:
module._does_info = prev
einfo.internal = True
job.on_failure(einfo)