Skip to content

Commit

Permalink
Added queue emptying function
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilim Štih committed May 24, 2018
1 parent b117ef2 commit 35ca940
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions arrayqueues/shared_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ def get(self, **kwargs):
self.read_queue.put(aritem[2])
return self.view.pop(aritem[2])

def clear(self):
""" Makes the queue empty
:return: nothing
"""
self.view = None

while True:
try:
self.queue.get()
except Empty:
break

while True:
try:
self.read_queue.get()
except Empty:
break

self.last_item = 0


class TimestampedArrayQueue(ArrayQueue):
""" A small extension to support timestamps saved alongside arrays
Expand Down

0 comments on commit 35ca940

Please sign in to comment.