Celery: Remove use of autoretry_for and retry_backoff
These features were for Celery 4.2.1, since this version has a regression, version 4.1.1 is used instead. The version 4.2.1 features are removed also and implemented in code. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import random
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth import get_user_model
|
||||
@@ -79,7 +80,7 @@ def task_delete_stubs():
|
||||
logger.info('Finshed')
|
||||
|
||||
|
||||
@app.task(bind=True, retry_backoff=True, max_retries=TASK_GENERATE_DODCUMENT_PAGE_IMAGE_RETRIES, retry_jitter=True)
|
||||
@app.task(bind=True, max_retries=TASK_GENERATE_DODCUMENT_PAGE_IMAGE_RETRIES)
|
||||
def task_generate_document_page_image(self, document_page_id, transformation_list=None, *args, **kwargs):
|
||||
"""
|
||||
Arguments:
|
||||
@@ -120,7 +121,9 @@ def task_generate_document_page_image(self, document_page_id, transformation_lis
|
||||
try:
|
||||
return task_core_function()
|
||||
except LockError as exception:
|
||||
raise self.retry(exc=exception)
|
||||
countdown = 2.0 ** self.request.retries
|
||||
countdown = random.randrange(countdown + 1)
|
||||
raise self.retry(countdown=countdown, exc=exception)
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
|
||||
@@ -20,8 +20,7 @@ def retry_on_lock_error(retries):
|
||||
else:
|
||||
retry_count = retry_count + 1
|
||||
timeout = 2 ** retry_count
|
||||
timeout = random.randrange(timeout + 1)
|
||||
time.sleep(timeout)
|
||||
# Add random jitter
|
||||
time.sleep(random.uniform(0.0, 1.0))
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
Reference in New Issue
Block a user