-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from celery import signals | ||
import logging | ||
|
||
logger = logging.getLogger("api_general:tasks") | ||
|
||
|
||
@signals.task_failure.connect | ||
@signals.task_revoked.connect | ||
def on_task_failure(**kwargs): | ||
"""Abort transaction on task errors.""" | ||
# celery exceptions will not be published to `sys.excepthook`. therefore we have to create another handler here. | ||
from traceback import format_tb | ||
|
||
logger.error( | ||
"[task:%s:%s]" | ||
% ( | ||
kwargs.get("task_id"), | ||
kwargs["sender"].request.correlation_id, | ||
) | ||
+ "\n" | ||
+ "".join(format_tb(kwargs.get("traceback", []))) | ||
+ "\n" | ||
+ str(kwargs.get("exception", "")) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters