summaryrefslogtreecommitdiff
path: root/logutils/queue.py
diff options
context:
space:
mode:
Diffstat (limited to 'logutils/queue.py')
-rw-r--r--logutils/queue.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/logutils/queue.py b/logutils/queue.py
index 03ed570..39be637 100644
--- a/logutils/queue.py
+++ b/logutils/queue.py
@@ -214,6 +214,15 @@ class QueueListener(object):
except queue.Empty:
break
+ def enqueue_sentinel(self):
+ """
+ Writes a sentinel to the queue to tell the listener to quit. This
+ implementation uses ``put_nowait()``. You may want to override this
+ method if you want to use timeouts or work with custom queue
+ implementations.
+ """
+ self.queue.put_nowait(self._sentinel)
+
def stop(self):
"""
Stop the listener.
@@ -223,7 +232,7 @@ class QueueListener(object):
may be some records still left on the queue, which won't be processed.
"""
self._stop.set()
- self.queue.put_nowait(self._sentinel)
+ self.enqueue_sentinel()
self._thread.join()
self._thread = None