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