如果服务脱机,请尝试将数据发布到后端服务,我希望芹菜继续提出请求,直到成功
我不断获得请求。Exceptions.connectionerror:用URL
超过最大检索我尝试使用请求重试类,因为这不是解决方案因为如果芹菜离线脱机,它不能保留任何数据
@shared_task(queue='development',autoretry_for=(Exception,ConnectionError))
def myfunction:
response = requests.post(URL),headers={"Content-Type":"application/json"},
json=obj)
对于任何寻找此答案的
@shared_task(queue='development',autoretry_for=(Exception,ConnectionError))
def myfunction:
response = requests.post(URL),headers={"Content-Type":"application/json"},
json=obj)
except ConnectionError as exc:
raise myfunction.retry(exc=exc)
except Exception as exc:
raise myfunction.retry(exc=exc)