我正在尝试在celery任务失败时进行重试。这是我的任务:
@shared_task(queue='es', bind=True, max_retries=3)
def update_station_es_index(doc_id, doc_body):
"""
Celery consumer method for updating ES.
"""
try:
#es_client is connecting to ElasticSearch
es_client.update_stations(id=doc_id, body=doc_body)
except Exception as e:
self.retry(exc=e)
但是当调用此任务时,我会收到此错误:
TypeError: update_station_es_index() takes 2 positional arguments but 3 were given
我在网络上没有找到关于这个错误的足够帮助,只有这个 github 问题,但那并没有解释太多。
有人能告诉我这里发生了什么以及解决方案是什么吗?
使用 Django2.0.5 和 celery4.2.0
(bind=True)
还是不使用? - Talha Anwarbind=True
。如果你不需要引用任务,则可以省略bind=True
。 - sytech