Add retry and rate limit support to the installation task
This commit is contained in:
@@ -164,8 +164,8 @@ class Installation(SingletonModel):
|
||||
|
||||
try:
|
||||
requests.post(FORM_SUBMIT_URL, data={'formkey': FORM_KEY, FORM_RECEIVER_FIELD: Property.get_reportable(as_json=True)}, timeout=TIMEOUT)
|
||||
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError):
|
||||
pass
|
||||
except Exception:
|
||||
raise
|
||||
else:
|
||||
self.is_first_run = False
|
||||
self.save()
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import requests
|
||||
|
||||
from mayan.celery import app
|
||||
|
||||
from .models import Installation
|
||||
|
||||
|
||||
@app.task
|
||||
def task_details_submit():
|
||||
details = Installation.objects.get()
|
||||
details.submit()
|
||||
def task_details_submit(max_retries=None, rate_limit='1/m', ignore_result=True):
|
||||
try:
|
||||
details = Installation.objects.get()
|
||||
details.submit()
|
||||
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exception:
|
||||
raise self.retry(exc=exception)
|
||||
|
||||
Reference in New Issue
Block a user