Skip to content

Commit cb9ce6f

Browse files
author
Ask Solem
committed
Worker crashes if CELERY_TASK_ERROR_WHITELIST is not iterable
1 parent 34cf6e5 commit cb9ce6f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

celery/worker/job.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,19 @@ def on_failure(self, exc_info):
414414
self.logger.error(self.error_msg.strip() % context)
415415

416416
task_obj = tasks.get(self.task_name, object)
417-
send_error_email = conf.CELERY_SEND_TASK_ERROR_EMAILS and not \
418-
task_obj.disable_error_emails and not any(
419-
isinstance(exc_info.exception, whexc)
420-
for whexc in
421-
conf.CELERY_TASK_ERROR_WHITELIST)
422-
if send_error_email:
417+
self.send_error_email(task_obj, context, exc_info.exception)
418+
419+
def send_error_email(self, task, context, exc,
420+
whitelist=conf.CELERY_TASK_ERROR_WHITELIST,
421+
enabled=conf.CELERY_SEND_TASK_ERROR_EMAILS,
422+
fail_silently=True):
423+
if enabled and not task.disable_error_emails:
424+
if whitelist is not None:
425+
if not isinstance(exc, tuple(whitelist)):
426+
return
423427
subject = self.email_subject.strip() % context
424428
body = self.email_body.strip() % context
425-
mail_admins(subject, body, fail_silently=True)
429+
return mail_admins(subject, body, fail_silently=fail_silently)
426430

427431
def __repr__(self):
428432
return '<%s: {name:"%s", id:"%s", args:"%s", kwargs:"%s"}>' % (

0 commit comments

Comments
 (0)