From 4c6f4039a278f4de03a7153882e3051f9499b185 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 8 Jun 2014 17:19:29 -0400 Subject: [PATCH] Ugly, but fixes a crawler threading bug. --- bitshift/crawler/indexer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bitshift/crawler/indexer.py b/bitshift/crawler/indexer.py index 8e3b9ac..c7973b6 100644 --- a/bitshift/crawler/indexer.py +++ b/bitshift/crawler/indexer.py @@ -107,9 +107,11 @@ class GitIndexer(threading.Thread): the queue. """ - while self.run_event.is_set(): - while self.index_queue.empty(): + while True: + while self.index_queue.empty() and self.run_event.is_set(): time.sleep(THREAD_QUEUE_SLEEP) + if not self.run_event.is_set(): + break repo = self.index_queue.get() self.index_queue.task_done() @@ -415,9 +417,11 @@ class _GitCloner(threading.Thread): for the `GitIndexer` to clone; otherwise, it is discarded. """ - while self.run_event.is_set(): - while self.clone_queue.empty(): + while True: + while self.index_queue.empty() and self.run_event.is_set(): time.sleep(THREAD_QUEUE_SLEEP) + if not self.run_event.is_set(): + break repo = self.clone_queue.get() self.clone_queue.task_done()