From 8ccc227b2db61e5986e88d50713032cd9a6bd118 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 17 Jun 2014 08:07:35 -0700 Subject: [PATCH] Handle task manager shutdown more correctly If a task manager was stopped with tasks in queue, they would not be processed. This could result in deadlocked threads if one of the long-running threads was waiting on a task while the main thread shut down a manager. Change-Id: I3f58c599d472d134984e63b41e9d493be9e9d70b --- nodepool/task_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodepool/task_manager.py b/nodepool/task_manager.py index 7105e4712..47db55e63 100644 --- a/nodepool/task_manager.py +++ b/nodepool/task_manager.py @@ -71,9 +71,11 @@ class TaskManager(threading.Thread): def run(self): last_ts = 0 - while self._running: + while True: task = self.queue.get() if not task: + if not self._running: + break continue while True: delta = time.time() - last_ts