Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting CELERY_ALWAYS_EAGER=True leads to TransactionManagementError #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion djcelery_transactions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8
from celery.task import task as base_task, Task
from celery import current_app
import djcelery_transactions.transaction_signals
from django.db import transaction
from functools import partial
Expand Down Expand Up @@ -52,7 +53,10 @@ def apply_async(cls, *args, **kwargs):
if delay_task:
_get_task_queue().append((cls, args, kwargs))
else:
return super(PostTransactionTask, cls).apply_async(*args, **kwargs)
apply_async_orig = super(PostTransactionTask, cls).apply_async
if current_app.conf.CELERY_ALWAYS_EAGER:
apply_async_orig = transaction.autocommit()(apply_async_orig)
return apply_async_orig(*args, **kwargs)


def _discard_tasks(**kwargs):
Expand Down