mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
logging: don't define QueueListener if Python has no thread support
This commit is contained in:
parent
b912c5a004
commit
cafa2efedb
3 changed files with 98 additions and 90 deletions
|
@ -27,7 +27,10 @@ To use, simply 'import logging.handlers' and log away!
|
||||||
import logging, socket, os, pickle, struct, time, re
|
import logging, socket, os, pickle, struct, time, re
|
||||||
from stat import ST_DEV, ST_INO, ST_MTIME
|
from stat import ST_DEV, ST_INO, ST_MTIME
|
||||||
import queue
|
import queue
|
||||||
import threading
|
try:
|
||||||
|
import threading
|
||||||
|
except ImportError:
|
||||||
|
threading = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import codecs
|
import codecs
|
||||||
|
@ -1218,7 +1221,8 @@ class QueueHandler(logging.Handler):
|
||||||
except:
|
except:
|
||||||
self.handleError(record)
|
self.handleError(record)
|
||||||
|
|
||||||
class QueueListener(object):
|
if threading:
|
||||||
|
class QueueListener(object):
|
||||||
"""
|
"""
|
||||||
This class implements an internal threaded listener which watches for
|
This class implements an internal threaded listener which watches for
|
||||||
LogRecords being added to a queue, removes them and passes them to a
|
LogRecords being added to a queue, removes them and passes them to a
|
||||||
|
|
|
@ -2093,6 +2093,8 @@ class QueueHandlerTest(BaseTest):
|
||||||
self.assertEqual(data.name, self.que_logger.name)
|
self.assertEqual(data.name, self.que_logger.name)
|
||||||
self.assertEqual((data.msg, data.args), (msg, None))
|
self.assertEqual((data.msg, data.args), (msg, None))
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
|
||||||
|
'logging.handlers.QueueListener required for this test')
|
||||||
def test_queue_listener(self):
|
def test_queue_listener(self):
|
||||||
handler = TestHandler(Matcher())
|
handler = TestHandler(Matcher())
|
||||||
listener = logging.handlers.QueueListener(self.queue, handler)
|
listener = logging.handlers.QueueListener(self.queue, handler)
|
||||||
|
|
|
@ -79,6 +79,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- logging: don't define QueueListener if Python has no thread support.
|
||||||
|
|
||||||
- Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get
|
- Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get
|
||||||
around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso.
|
around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue