Skip to content

Commit

Permalink
Retry routing task 5 times when signal is locked
Browse files Browse the repository at this point in the history
  • Loading branch information
bartjkdp committed Apr 26, 2023
1 parent 3705c22 commit e6a8534
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/signals/apps/signals/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.core.management import call_command
from django.db import connection
from django.db.models import Q
from django.db.utils import OperationalError
from django.utils import timezone

from signals.apps.services.domain.auto_create_children.service import AutoCreateChildrenService
Expand All @@ -24,7 +25,8 @@
dsl_service = SignalDslService()


@app.task
# OperationalError catches the psycopg2.errors.LockNotAvailable exception
@app.task(autoretry_for=(OperationalError, ), max_retries=5, default_retry_delay=10)
def apply_routing(signal_id):
signal = Signal.objects.get(pk=signal_id)
dsl_service.process_routing_rules(signal)
Expand Down

0 comments on commit e6a8534

Please sign in to comment.