Skip to content

Commit

Permalink
Add missing event trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-indyk authored and krise3k committed Nov 23, 2015
1 parent 25661c9 commit 1ffd513
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 1ffd513

Please sign in to comment.