(Merge 3.2) logging: don't define QueueListener if Python has no thread support

This commit is contained in:
Victor Stinner 2011-05-02 16:14:16 +02:00
commit 59bec36b1c
3 changed files with 106 additions and 98 deletions

View File

@ -27,7 +27,10 @@
import logging, socket, os, pickle, struct, time, re
from stat import ST_DEV, ST_INO, ST_MTIME
import queue
try:
import threading
except ImportError:
threading = None
try:
import codecs
@ -1218,6 +1221,7 @@ def emit(self, record):
except:
self.handleError(record)
if threading:
class QueueListener(object):
"""
This class implements an internal threaded listener which watches for

View File

@ -2634,6 +2634,8 @@ def test_queue_handler(self):
self.assertEqual(data.name, self.que_logger.name)
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):
handler = TestHandler(Matcher())
listener = logging.handlers.QueueListener(self.queue, handler)

View File

@ -132,6 +132,8 @@ Core and Builtins
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
around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso.