Skip to content

Commit

Permalink
Fix corner case with joining processes/queues (#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin authored and aoen committed May 9, 2016
1 parent 0ed36a1 commit 0e5fb90
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions airflow/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,16 +751,18 @@ def _execute(self):
self.logger.info("Starting {} scheduler jobs".format(len(jobs)))
for j in jobs:
j.start()

while any(j.is_alive() for j in jobs):
while not tis_q.empty():
ti_key, pickle_id = tis_q.get()
dag = dagbag.dags[ti_key[0]]
task = dag.get_task(ti_key[1])
ti = TI(task, ti_key[2])
self.executor.queue_task_instance(ti, pickle_id=pickle_id)

for j in jobs:
j.join()

while not tis_q.empty():
ti_key, pickle_id = tis_q.get()
dag = dagbag.dags[ti_key[0]]
task = dag.get_task(ti_key[1])
ti = TI(task, ti_key[2])
self.executor.queue_task_instance(ti, pickle_id=pickle_id)

self.logger.info("Done queuing tasks, calling the executor's "
"heartbeat")
duration_sec = (datetime.now() - loop_start_dttm).total_seconds()
Expand Down

0 comments on commit 0e5fb90

Please sign in to comment.