0
我想retry
(official doc)引发异常时的任务。芹菜允许通过使用形式self.retry(...)
芹菜send_task和异常时重试
现在,我不知道如何用户self
因为我有一个没有任何类的功能。
我的代码是这样的
.. imports ...
app = Celery('elasticcelery')
@app.task(name='rm_doc')
def rm_doc(schema_id, id):
es = Elasticsearch(es_ip)
try:
res = es.delete(schema_id, 'doc', id)
except NotFoundError as e:
<here goes the retry>
而且它以这种方式从另一个服务叫做:
app_celery = Celery('celeryelastic')
app_celery.config_from_object('django.conf:settings')
app_celery.send_task('rm_doc', kwargs={"schema_id": schema_id, "id": document_id},)
现在
,我要补充的self.retry
但在我的方法没有self
。
我该如何继续?
PS:我尝试添加self
作为参数,但是这样做失败了,因为当第一次从远程调用任务时没有映射。