From 2dfe1fe890af35a9d6238d9c8300da316edf105c Mon Sep 17 00:00:00 2001 From: Nicolas Delaby Date: Fri, 7 Nov 2014 11:33:07 +0100 Subject: [PATCH] During testing do not postpone execution of the tasks --- django_atomic_celery/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)