Skip to content

Commit

Permalink
Avoid reading global variables in worker. (#2077)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalvdans authored and Tarrasch committed Apr 5, 2017
1 parent 1860d0b commit 9daa1df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion luigi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def _add(self, task, is_complete):
elif _is_external(task):
deps = None
status = PENDING
runnable = worker().retry_external_tasks
runnable = self._config.retry_external_tasks
task.trigger_event(Event.DEPENDENCY_MISSING, task)
logger.warning('Data for %s does not exist (yet?). The task is an '
'external data depedency, so it can not be run from'
Expand Down
21 changes: 21 additions & 0 deletions test/worker_external_task_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ def test_external_dependency_worker_is_patient(self):

self.assertGreaterEqual(test_task.dependency.times_called, 5)

def test_external_dependency_bare(self):
"""
Test ExternalTask without altering global settings.
"""
assert luigi.worker.worker().retry_external_tasks is False

test_task = TestTask(tempdir=self.tempdir, complete_after=5)

scheduler = luigi.scheduler.Scheduler(retry_delay=0.01,
prune_on_get_work=True)
with luigi.worker.Worker(
retry_external_tasks=True, scheduler=scheduler,
keep_alive=True, wait_interval=0.00001, wait_jitter=0) as w:
w.add(test_task)
w.run()

assert os.path.exists(test_task.dep_path)
assert os.path.exists(test_task.output_path)

self.assertGreaterEqual(test_task.dependency.times_called, 5)

@with_config({'worker': {'retry_external_tasks': 'true', },
'scheduler': {'retry_delay': '0.0'}})
def test_external_task_complete_but_missing_dep_at_runtime(self):
Expand Down

0 comments on commit 9daa1df

Please sign in to comment.