mirror of
https://github.com/pretix/pretix.git
synced 2026-08-28 13:34:40 +00:00
Fix #249 -- Blacklist some exceptions for celeries error reporting
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
from celery.utils.mail import ErrorMail
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pretix.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pretix.settings")
|
||||||
|
|
||||||
@@ -8,5 +9,21 @@ from django.conf import settings
|
|||||||
|
|
||||||
app = Celery('pretix')
|
app = Celery('pretix')
|
||||||
|
|
||||||
|
|
||||||
|
class MyErrorMail(ErrorMail):
|
||||||
|
|
||||||
|
def should_send(self, context, exc):
|
||||||
|
from pretix.base.services.orders import OrderError
|
||||||
|
from pretix.base.services.cart import CartError
|
||||||
|
|
||||||
|
blacklist = (OrderError, CartError)
|
||||||
|
return not isinstance(exc, blacklist)
|
||||||
|
|
||||||
|
|
||||||
app.config_from_object('django.conf:settings')
|
app.config_from_object('django.conf:settings')
|
||||||
|
app.conf.CELERY_ANNOTATIONS = {
|
||||||
|
'*': {
|
||||||
|
'ErrorMail': MyErrorMail,
|
||||||
|
}
|
||||||
|
}
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||||
|
|||||||
Reference in New Issue
Block a user