Skip to content

Commit

Permalink
Added exception for empty Queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Otvos committed Oct 30, 2014
1 parent e989475 commit c27ffbe
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions s3stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ def __init__(self, outqueue, outfile):

def run(self):
while True:
data = self.queue.get()
self.outfile.write(data)
self.queue.task_done()
try:
data = self.queue.get()
self.outfile.write(data)
self.queue.task_done()
except Queue.Empty:
break

class DownloadLogThread(threading.Thread):
"""
Expand All @@ -182,10 +185,13 @@ def read_log(self, item):

def run(self):
while True:
item = self.in_queue.get()
data = self.read_log(item)
self.out_queue.put(data)
self.in_queue.task_done()
try:
item = self.in_queue.get()
data = self.read_log(item)
self.out_queue.put(data)
self.in_queue.task_done()
except Queue.Empty:
break


class S3Stat(object):
Expand Down Expand Up @@ -310,7 +316,7 @@ def run(self, format="json"):
out = json.loads(out)
except ValueError as e:
return self.process_error(e, out)

self.process_results(out)

return True
Expand Down

0 comments on commit c27ffbe

Please sign in to comment.