From 6c1813dd34c858cf79e4ebab830b7cbe977792f2 Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Mon, 11 Jun 2012 11:39:18 -0700 Subject: [PATCH] Make swift not hang on error. Before, if a QueueFunctionThread's function raised an exception, then its thread would log the exception and exit, leaving the rest of the jobs in the queue and ensuring that the swift client would hang. Now, the exception is logged and processing continues, so all the messages get handled eventually and the client exits. Change-Id: I43d4df212847a2a85732b304de319ea2cce82ddd --- bin/swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/swift b/bin/swift index 354f82c..aecdbb5 100755 --- a/bin/swift +++ b/bin/swift @@ -83,20 +83,21 @@ class QueueFunctionThread(Thread): self.exc_infos = [] def run(self): - try: - while True: + while True: + try: + item = self.queue.get_nowait() + except Empty: + if self.abort: + break + sleep(0.01) + else: try: - item = self.queue.get_nowait() if not self.abort: self.func(item, *self.args, **self.kwargs) + except Exception: + self.exc_infos.append(exc_info()) + finally: self.queue.task_done() - except Empty: - if self.abort: - break - sleep(0.01) - except Exception: - self.exc_infos.append(exc_info()) - st_delete_help = ''' delete --all OR delete container [--leave-segments] [object] [object] ...