當前位置: 首頁>>代碼示例>>Python>>正文


Python einfo.ExceptionInfo類代碼示例

本文整理匯總了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)
開發者ID:yingzong,項目名稱:celery,代碼行數:26,代碼來源:trace.py

示例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)
開發者ID:hanshoudong,項目名稱:celery,代碼行數:16,代碼來源:test_request.py

示例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)
開發者ID:rhayesbite,項目名稱:celery,代碼行數:16,代碼來源:test_request.py

示例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)
開發者ID:arunsuresh,項目名稱:celery,代碼行數:16,代碼來源:test_request.py

示例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)
開發者ID:kalefranz,項目名稱:celery,代碼行數:18,代碼來源:trace.py

示例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)
開發者ID:alekibango,項目名稱:celery,代碼行數:21,代碼來源:test_request.py

示例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)
開發者ID:Arizona-Tecnologia,項目名稱:celery,代碼行數:21,代碼來源:test_request.py


注:本文中的billiard.einfo.ExceptionInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。