我正在尝试重试失败的任务,并返回以下代码:
@task(bind=True)
def update_listing(self, listing_object, retailer):
try:
listing = _update_listing(listing_object, retailer)
except Exception as exc:
raise self.retry(exc=exc)
return listing
这将导致引发以下错误:
^{pr2}$我不知道这个错误与什么有关,也不知道如何修复它。我调用重试方法的方式正确吗?在
我的芹菜配置文件如下所示:
BROKER_URL = "redis://localhost:6379/0"
CELERY_IMPORTS = ("tasks", )
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"
CELERY_IGNORE_RESULT = True
编辑:完整堆栈跟踪:
Traceback (most recent call last):
File "/home/my-project/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 218, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/my-project/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 398, in __protected_call__
return self.run(*args, **kwargs)
File "/home/my-project/tasks.py", line 156, in update_listing
raise self.retry(exc=exc)
File "/home/my-project/venv/local/lib/python2.7/site-packages/celery/app/task.py", line 666, in retry
raise Reject(exc, requeue=True)
Reject: (TypeError('__init__() takes exactly 2 arguments (3 given)',), True)
不能使用regular使用的
@task
修饰符装饰实例方法功能。你必须使用from celery.contrib.methods import task
而不是常规的:
from celery import task
它可能有一些注意事项,因为它是从3.0版开始试验的,请参考以下链接:
http://docs.celeryproject.org/en/latest/reference/celery.contrib.methods.html
相关问题 更多 >
编程相关推荐