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
This commit is contained in:
Samuel Merritt 2012-06-11 11:39:18 -07:00
parent a92a0fa0e4
commit 6c1813dd34

View File

@ -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] ...