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

Fix emailing of unexpected error in Worker._announce_scheduling_failure. #2191

Merged
merged 2 commits into from
Jul 30, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion luigi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ def _announce_scheduling_failure(self, task, expl):
owners=task._owner_list(),
)
except Exception:
raise
formatted_traceback = traceback.format_exc()
self._email_unexpected_error(task, formatted_traceback)
raise

def _email_complete_error(self, task, formatted_traceback):
self._announce_scheduling_failure(task, formatted_traceback)
Expand Down
20 changes: 20 additions & 0 deletions test/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,26 @@ def complete(self):
"1 scheduling failure" in email and 'a_owner@test.com' in email
for email in emails))

@email_patch
def test_announce_scheduling_failure_unexpected_error(self, emails):

class A(DummyTask):
owner_email = 'a_owner@test.com'

def complete(self):
pass

scheduler = Scheduler(batch_emails=True)
worker = Worker(scheduler)
a = A()

with mock.patch.object(worker._scheduler, 'announce_scheduling_failure', side_effect=Exception('Unexpected')),\
self.assertRaises(Exception):
worker.add(a)
self.assertTrue(len(emails) == 2) # One for `complete` error, one for exception in announcing.
self.assertTrue('Luigi: Framework error while scheduling' in emails[1])
self.assertTrue('a_owner@test.com' in emails[1])

@email_patch
def test_requires_error(self, emails):
class A(DummyTask):
Expand Down