diff options
author | Aaron Gordon <aaronsgordon@yahoo.com> | 2012-12-19 07:31:11 (GMT) |
---|---|---|
committer | Aaron Gordon <aaronsgordon@yahoo.com> | 2012-12-19 07:31:11 (GMT) |
commit | 748ff0fee8e61e6bfc9ee751f5cceb817c4fcbc9 (patch) | |
tree | 1bec9efc0588ac0cbd76787601d6ed5a7f679a9f /misc/dumpqueue.py | |
parent | 421c2039856dae7b79882af5e0a50e2ab6a396cf (diff) |
Diffstat (limited to 'misc/dumpqueue.py')
-rw-r--r-- | misc/dumpqueue.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/misc/dumpqueue.py b/misc/dumpqueue.py new file mode 100644 index 0000000..5a5b744 --- /dev/null +++ b/misc/dumpqueue.py @@ -0,0 +1,20 @@ +""" +See documentation for dump_queue defined here. +""" +import Queue + + +def dump_queue(queue): + """ + Empties all pending items in a queue + and returns them in a list. + """ + result=[] + + while True: + try: + thing=queue.get(block=False) + result.append(thing) + except Queue.Empty: + return result + |