From 73f876c8250def6760d76d1bbfac908f1c366fd6 Mon Sep 17 00:00:00 2001 From: Olivier R-D Date: Wed, 28 Aug 2013 15:43:59 +0200 Subject: [PATCH] split try_pop and pop --- urx/urrtmon.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/urx/urrtmon.py b/urx/urrtmon.py index e5279aa..27eb264 100644 --- a/urx/urrtmon.py +++ b/urx/urrtmon.py @@ -181,7 +181,7 @@ class URRTMonitor(threading.Thread): def stop_buffering(self): self._buffering = False - def pop_buffer(self): + def try_pop_buffer(self): """ return oldest value in buffer """ @@ -191,6 +191,17 @@ class URRTMonitor(threading.Thread): else: return None + def pop_buffer(self): + """ + return oldest value in buffer + """ + while True: + with self._buffer_lock: + if len(self._buffer) > 0: + return self._buffer.pop(0) + time.sleep(0.001) + + def get_buffer(self): """ return a copy of the entire buffer