我在Django celery应用程序中有一个简单的任务,例如
@shared_task
def task(some_arg):
# Do some stuff
if some_error:
raise Exception("Something went wrong")
一切正常,任务按预期失败:
[...:ERROR/ForkPoolWorker-2] Task task[some-id] raised unexpected: Exception('Something went wrong',)
但是当库引发自定义异常时,我得到以下输出:
[...: WARNING/ForkPoolWorker-2] --- Logging error ---
[...: ERROR/MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: exitcode 0.',)
Traceback (most recent call last):
File ".../lib/python3.6/site-packages/billiard/pool.py", line 1226, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: exitcode 0.
该如何调试?
自定义Error类如下所示:
class faultType(structType, Error):
def __init__(self, faultcode = "", faultstring = "", detail = None):
self.faultcode = faultcode
self.faultstring = faultstring
if detail != None:
self.detail = detail
structType.__init__(self, None, 0)
...
答案 0 :(得分:0)