This commit is contained in:
Brett Cannon 2012-02-23 18:30:04 -05:00
commit dcb30cf959
6 changed files with 62 additions and 32 deletions

View File

@ -77,6 +77,7 @@ d18e9d71f369d8211f6ac87252c6d3211f9bd09f v3.1.3rc1
a4f75773c0060cee38b0bb651a7aba6f56b0e996 v3.1.3 a4f75773c0060cee38b0bb651a7aba6f56b0e996 v3.1.3
32fcb9e94985cb19ce37ba9543f091c0dbe9d7dd v3.1.4rc1 32fcb9e94985cb19ce37ba9543f091c0dbe9d7dd v3.1.4rc1
c918ec9f3a76d6afedfbb5d455004de880443a3d v3.1.4 c918ec9f3a76d6afedfbb5d455004de880443a3d v3.1.4
ee26aca3219cf4bb0b93352e83edcc9cb28c7802 v3.1.5rc1
b37b7834757492d009b99cf0ca4d42d2153d7fac v3.2a1 b37b7834757492d009b99cf0ca4d42d2153d7fac v3.2a1
56d4373cecb73c8b45126ba7b045b3c7b3f94b0b v3.2a2 56d4373cecb73c8b45126ba7b045b3c7b3f94b0b v3.2a2
da012d9a2c23d144e399d2e01a55b8a83ad94573 v3.2a3 da012d9a2c23d144e399d2e01a55b8a83ad94573 v3.2a3

View File

@ -240,7 +240,7 @@ default values. The arguments that are most commonly needed are:
When *stdout* or *stderr* are pipes and *universal_newlines* is When *stdout* or *stderr* are pipes and *universal_newlines* is
:const:`True` then the output data is assumed to be encoded as UTF-8 and :const:`True` then the output data is assumed to be encoded as UTF-8 and
will automatically be decoded to text. All line endings will be converted will automatically be decoded to text. All line endings will be converted
to ``'\n'`` as described for the universal newlines `'U'`` mode argument to ``'\n'`` as described for the universal newlines ``'U'`` mode argument
to :func:`open`. to :func:`open`.
If *shell* is :const:`True`, the specified command will be executed through If *shell* is :const:`True`, the specified command will be executed through

View File

@ -195,7 +195,7 @@ always available.
be set at build time with the ``--exec-prefix`` argument to the be set at build time with the ``--exec-prefix`` argument to the
:program:`configure` script. Specifically, all configuration files (e.g. the :program:`configure` script. Specifically, all configuration files (e.g. the
:file:`pyconfig.h` header file) are installed in the directory :file:`pyconfig.h` header file) are installed in the directory
:file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are
installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y*
is the version number of Python, for example ``3.2``. is the version number of Python, for example ``3.2``.
@ -756,6 +756,7 @@ always available.
always use the ``startswith`` idiom presented above. always use the ``startswith`` idiom presented above.
.. seealso:: .. seealso::
:attr:`os.name` has a coarser granularity. :func:`os.uname` gives :attr:`os.name` has a coarser granularity. :func:`os.uname` gives
system-dependent version information. system-dependent version information.
@ -771,7 +772,7 @@ always available.
argument to the :program:`configure` script. The main collection of Python argument to the :program:`configure` script. The main collection of Python
library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}`` library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}``
while the platform independent header files (all except :file:`pyconfig.h`) are while the platform independent header files (all except :file:`pyconfig.h`) are
stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version
number of Python, for example ``3.2``. number of Python, for example ``3.2``.

View File

@ -228,8 +228,9 @@ The module defines the following functions and data items:
.. function:: monotonic() .. function:: monotonic()
Monotonic clock. The reference point of the returned value is undefined so Monotonic non-decreasing clock. The clock is not related to the system clock
only the difference of consecutive calls is valid. and cannot go backward. The reference point of the returned
value is undefined so only the difference of consecutive calls is valid.
.. versionadded:: 3.3 .. versionadded:: 3.3

View File

@ -16,9 +16,9 @@
""" """
Logging package for Python. Based on PEP 282 and comments thereto in Logging package for Python. Based on PEP 282 and comments thereto in
comp.lang.python, and influenced by Apache's log4j system. comp.lang.python.
Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved. Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away! To use, simply 'import logging' and log away!
""" """
@ -914,8 +914,12 @@ class StreamHandler(Handler):
""" """
Flushes the stream. Flushes the stream.
""" """
self.acquire()
try:
if self.stream and hasattr(self.stream, "flush"): if self.stream and hasattr(self.stream, "flush"):
self.stream.flush() self.stream.flush()
finally:
self.release()
def emit(self, record): def emit(self, record):
""" """
@ -964,12 +968,16 @@ class FileHandler(StreamHandler):
""" """
Closes the stream. Closes the stream.
""" """
self.acquire()
try:
if self.stream: if self.stream:
self.flush() self.flush()
if hasattr(self.stream, "close"): if hasattr(self.stream, "close"):
self.stream.close() self.stream.close()
StreamHandler.close(self) StreamHandler.close(self)
self.stream = None self.stream = None
finally:
self.release()
def _open(self): def _open(self):
""" """

View File

@ -1,4 +1,4 @@
# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # Copyright 2001-2012 by Vinay Sajip. All Rights Reserved.
# #
# Permission to use, copy, modify, and distribute this software and its # Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, # documentation for any purpose and without fee is hereby granted,
@ -16,10 +16,9 @@
""" """
Additional handlers for the logging package for Python. The core package is Additional handlers for the logging package for Python. The core package is
based on PEP 282 and comments thereto in comp.lang.python, and influenced by based on PEP 282 and comments thereto in comp.lang.python.
Apache's log4j system.
Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away! To use, simply 'import logging.handlers' and log away!
""" """
@ -594,10 +593,14 @@ class SocketHandler(logging.Handler):
""" """
Closes the socket. Closes the socket.
""" """
self.acquire()
try:
if self.sock: if self.sock:
self.sock.close() self.sock.close()
self.sock = None self.sock = None
logging.Handler.close(self) logging.Handler.close(self)
finally:
self.release()
class DatagramHandler(SocketHandler): class DatagramHandler(SocketHandler):
""" """
@ -792,8 +795,12 @@ class SysLogHandler(logging.Handler):
""" """
Closes the socket. Closes the socket.
""" """
self.acquire()
try:
self.socket.close() self.socket.close()
logging.Handler.close(self) logging.Handler.close(self)
finally:
self.release()
def mapPriority(self, levelName): def mapPriority(self, levelName):
""" """
@ -1137,7 +1144,11 @@ class BufferingHandler(logging.Handler):
This version just zaps the buffer to empty. This version just zaps the buffer to empty.
""" """
self.acquire()
try:
self.buffer = [] self.buffer = []
finally:
self.release()
def close(self): def close(self):
""" """
@ -1187,18 +1198,26 @@ class MemoryHandler(BufferingHandler):
The record buffer is also cleared by this operation. The record buffer is also cleared by this operation.
""" """
self.acquire()
try:
if self.target: if self.target:
for record in self.buffer: for record in self.buffer:
self.target.handle(record) self.target.handle(record)
self.buffer = [] self.buffer = []
finally:
self.release()
def close(self): def close(self):
""" """
Flush, set the target to None and lose the buffer. Flush, set the target to None and lose the buffer.
""" """
self.flush() self.flush()
self.acquire()
try:
self.target = None self.target = None
BufferingHandler.close(self) BufferingHandler.close(self)
finally:
self.release()
class QueueHandler(logging.Handler): class QueueHandler(logging.Handler):