Skip to content

Commit

Permalink
Fixed the tests for 1.6, CELERY_EAGER now working differently
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasgrasset committed Oct 31, 2014
1 parent dadb14b commit 783459b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion djcelery_transactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def apply_async(self, *args, **kwargs):
# Delay the task unless the client requested otherwise or transactions
# aren't being managed (i.e. the signal handlers won't send the task).
connection = get_connection()
if connection.in_atomic_block and not getattr(current_app.conf, 'CELERY_ALWAYS_EAGER', False):
if connection.in_atomic_block:
_get_task_queue().append((self, args, kwargs))
else:
return self.original_apply_async(*args, **kwargs)
Expand Down
8 changes: 4 additions & 4 deletions djcelery_transactions/transaction_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __patched__exit__(self, exc_type, exc_value, traceback):
try:
connection.savepoint_rollback(sid)
transaction.signals.post_rollback.send(None)
except Error:
except Exception:
# If rolling back to a savepoint fails, mark for
# rollback at a higher level and avoid shadowing
# the original exception.
Expand All @@ -175,7 +175,7 @@ def __patched__exit__(self, exc_type, exc_value, traceback):
try:
connection.rollback()
transaction.signals.post_rollback.send(None)
except Error:
except Exception:
# An error during rollback means that something
# went wrong with the connection. Drop it.
connection.close()
Expand All @@ -193,7 +193,7 @@ def __patched__exit__(self, exc_type, exc_value, traceback):
try:
connection.savepoint_rollback(sid)
transaction.signals.post_rollback.send(None)
except Error:
except Exception:
# If rolling back to a savepoint fails, mark for
# rollback at a higher level and avoid shadowing
# the original exception.
Expand All @@ -203,7 +203,7 @@ def __patched__exit__(self, exc_type, exc_value, traceback):
try:
connection.rollback()
transaction.signals.post_rollback.send(None)
except Error:
except Exception:
# An error during rollback means that something
# went wrong with the connection. Drop it.
connection.close()
Expand Down
6 changes: 3 additions & 3 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from djcelery_transactions import task

from django.db import transaction
from django.db.transaction import atomic
from django.test import TransactionTestCase

my_global = []
Expand Down Expand Up @@ -31,7 +31,7 @@ def test_commited_transaction_fire_task(self):
"""Check that task is consumed when no exception happens
"""

@transaction.commit_on_success
@atomic()
def do_something():
my_task.delay()

Expand All @@ -42,7 +42,7 @@ def test_rollbacked_transaction_discard_task(self):
"""Check that task is not consumed when exception happens
"""

@transaction.commit_on_success
@atomic()
def do_something():
my_task.delay()
raise SpecificException
Expand Down

0 comments on commit 783459b

Please sign in to comment.