diff --git a/django_atomic_celery/__init__.py b/django_atomic_celery/__init__.py index 94aab86..97193c9 100644 --- a/django_atomic_celery/__init__.py +++ b/django_atomic_celery/__init__.py @@ -2,6 +2,7 @@ import threading from collections import defaultdict from celery.task import task as base_task, Task +from django.conf import settings from django.dispatch import receiver from django.db import DEFAULT_DB_ALIAS from functools import partial @@ -91,7 +92,8 @@ def apply_async(cls, args=(), kwargs=None, *a, **kw): t = ConditionalTask(cls, args, kwargs, *a, **kw) - if task_queue_stack: + if task_queue_stack and not getattr(settings, + 'CELERY_ALWAYS_EAGER', False): logger.debug('Scheduling task %s if transaction block is ' 'successful' % (t.description)) task_queue_stack[-1].append(t)