Skip to content

Commit fc6c509

Browse files
author
Ask Solem
committed
Tests passing again
1 parent 41b1b8f commit fc6c509

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

celery/tests/test_worker_job.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def mock_mail_admins(*args, **kwargs):
139139
try:
140140
tw = TaskRequest(mytask.name, gen_unique_id(), [1], {"f": "x"})
141141
try:
142-
raise KeyError("foo")
143-
except KeyError:
142+
raise KeyError("moofoobar")
143+
except:
144144
einfo = ExceptionInfo(sys.exc_info())
145145

146146
tw.on_failure(einfo)
@@ -455,7 +455,8 @@ def _test_on_failure(self, exception):
455455

456456
logfh = StringIO()
457457
tw.logger.handlers = []
458-
tw.logger = setup_logger(logfile=logfh, loglevel=logging.INFO)
458+
tw.logger = setup_logger(logfile=logfh, loglevel=logging.INFO,
459+
root=False)
459460

460461
from celery import conf
461462
conf.CELERY_SEND_TASK_ERROR_EMAILS = True

celery/worker/job.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ def on_failure(self, exc_info):
434434
self.logger.error(self.error_msg.strip() % context)
435435

436436
task_obj = tasks.get(self.task_name, object)
437-
self.send_error_email(task_obj, context, exc_info.exception)
437+
self.send_error_email(task_obj, context, exc_info.exception,
438+
enabled=conf.CELERY_SEND_TASK_ERROR_EMAILS,
439+
whitelist=conf.CELERY_TASK_ERROR_WHITELIST)
438440

439441
def send_error_email(self, task, context, exc,
440-
whitelist=conf.CELERY_TASK_ERROR_WHITELIST,
441-
enabled=conf.CELERY_SEND_TASK_ERROR_EMAILS,
442-
fail_silently=True):
442+
whitelist=None, enabled=False, fail_silently=True):
443443
if enabled and not task.disable_error_emails:
444-
if whitelist is not None:
444+
if whitelist:
445445
if not isinstance(exc, tuple(whitelist)):
446446
return
447447
subject = self.email_subject.strip() % context

0 commit comments

Comments
 (0)