summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-02-25 15:56:55 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-02-25 15:56:55 (GMT)
commitaa7c1792855fa7db7b4c2f71573e0c35b0fe2ea1 (patch)
treee8342d52eb9049dc22407f2a12b017895f763888 /Lib/logging
parent8f36af7a4c9409a673412e4bdfbad76d700abc3a (diff)
downloadcpython-aa7c1792855fa7db7b4c2f71573e0c35b0fe2ea1.zip
cpython-aa7c1792855fa7db7b4c2f71573e0c35b0fe2ea1.tar.gz
cpython-aa7c1792855fa7db7b4c2f71573e0c35b0fe2ea1.tar.bz2
Improved QueueListener implementation - queue sentinel addition made extensible.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/handlers.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 96384bd..57b2057 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1307,6 +1307,16 @@ class QueueListener(object):
except queue.Empty:
break
+ def enqueue_sentinel(self):
+ """
+ This is used to enqueue the sentinel record.
+
+ The base 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.
@@ -1316,6 +1326,6 @@ 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