Skip to content

Commit

Permalink
Merge pull request #1422 from krise3k/master
Browse files Browse the repository at this point in the history
Add missing event.BROKEN_TASK trigger
  • Loading branch information
erikbern committed Nov 24, 2015
2 parents 25661c9 + 1ffd513 commit b9e105c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion luigi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,11 @@ def _add(self, task, is_complete):
else:
try:
deps = task.deps()
except Exception:
except Exception as ex:
formatted_traceback = traceback.format_exc()
self.add_succeeded = False
self._log_dependency_error(task, formatted_traceback)
task.trigger_event(Event.BROKEN_TASK, task, ex)
self._email_dependency_error(task, formatted_traceback)
return
status = PENDING
Expand Down
25 changes: 25 additions & 0 deletions test/event_callbacks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ def run(self):
raise DummyException()


class TaskWithBrokenDependency(Task):

def requires(self):
raise DummyException()

def run(self):
pass


class TaskWithCallback(Task):

def run(self):
Expand Down Expand Up @@ -88,6 +97,22 @@ def test_failure(self):
self.assertEqual(len(exceptions), 1)
self.assertTrue(isinstance(exceptions[0], DummyException))

def test_broken_dependency(self):
failures = []
exceptions = []

@TaskWithBrokenDependency.event_handler(Event.BROKEN_TASK)
def failure(task, exception):
failures.append(task)
exceptions.append(exception)

t = TaskWithBrokenDependency()
build([t], local_scheduler=True)

self.assertEqual(failures, [t])
self.assertEqual(len(exceptions), 1)
self.assertTrue(isinstance(exceptions[0], DummyException))

def test_custom_handler(self):
dummies = []

Expand Down

0 comments on commit b9e105c

Please sign in to comment.