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

Log a warning when tasks are discarded #18

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: 6 additions & 0 deletions djcelery_transactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from django.db import transaction
from functools import partial
import threading
import logging

logger = logging.getLogger(__name__)


# Thread-local data (task queue).
Expand Down Expand Up @@ -67,6 +70,9 @@ def _discard_tasks(**kwargs):
"""Discards all delayed Celery tasks.

Called after a transaction is rolled back."""
num_tasks = len(_get_task_queue())
if num_tasks:
logger.warning('%d tasks discarded because of transaction rollback!', num_tasks)
_get_task_queue()[:] = []


Expand Down