我怎样才能让芹菜重试请求直到成功
How can i make celery retry the for a requests until succesfull
尝试post数据到后端服务如果服务离线我希望芹菜继续发出请求直到成功
我不断收到 requests.exceptions.ConnectionError:
url
超出最大重试次数
我已经尝试使用请求重试 class,因为这不是解决方案
因为如果 celery 脱机它不会保留任何数据我正在寻找 celery 只不断尝试的解决方案
@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)
尝试post数据到后端服务如果服务离线我希望芹菜继续发出请求直到成功
我不断收到 requests.exceptions.ConnectionError: url
超出最大重试次数我已经尝试使用请求重试 class,因为这不是解决方案 因为如果 celery 脱机它不会保留任何数据我正在寻找 celery 只不断尝试的解决方案
@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)