Skip to content

Commit

Permalink
Add retry for failed model reg tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
sambles committed Feb 2, 2023
1 parent 82c78a5 commit ebecb93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/oasisapi/analyses/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from .models import AnalysisTaskStatus
from .task_controller import get_analysis_task_controller
from ..celery_app import celery_app
from ..celery_app import celery_app, server_task_kwargs


logger = get_task_logger(__name__)
Expand Down Expand Up @@ -287,7 +287,7 @@ def log_worker_monitor(sender, **k):
logger.info('AWS_IS_GZIPPED: {}'.format(settings.AWS_IS_GZIPPED))


@celery_app.task(name='run_register_worker')
@celery_app.task(name='run_register_worker', *worker_task_kwargs)
def run_register_worker(m_supplier, m_name, m_id, m_settings, m_version, m_conf):
logger.info('model_supplier: {}, model_name: {}, model_id: {}'.format(m_supplier, m_name, m_id))
try:
Expand Down
6 changes: 6 additions & 0 deletions src/server/oasisapi/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
celery_app = Celery('oasisapi')
celery_app.config_from_object('django.conf:settings')
celery_app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

server_task_kwargs = {
'autoretry_for': (Exception,),
'max_retries': 2, # The task will be run max_retries + 1 times
'default_retry_delay': 5, # A small delay to recover from temporary bad states
}

0 comments on commit ebecb93

Please sign in to comment.