diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-02-23 20:51:18 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-02-23 20:51:18 (GMT) |
commit | 323e4fb864301654a798e273409b645d097d02a5 (patch) | |
tree | 18bda12823599e53882f7faaf2737512e95979f0 /Lib/logging/handlers.py | |
parent | 57c223791de6edb7fd302bd682630ab1e259a06b (diff) | |
parent | f05090372a43966266a8d20b9c21d348e417a48e (diff) | |
download | cpython-323e4fb864301654a798e273409b645d097d02a5.zip cpython-323e4fb864301654a798e273409b645d097d02a5.tar.gz cpython-323e4fb864301654a798e273409b645d097d02a5.tar.bz2 |
Merged fix added for recent changes in non-threading environments.
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r-- | Lib/logging/handlers.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 0107853..ee0096a 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -593,11 +593,14 @@ class SocketHandler(logging.Handler): """ Closes the socket. """ - with self.lock: + self.acquire() + try: if self.sock: self.sock.close() self.sock = None logging.Handler.close(self) + finally: + self.release() class DatagramHandler(SocketHandler): """ @@ -792,9 +795,12 @@ class SysLogHandler(logging.Handler): """ Closes the socket. """ - with self.lock: + self.acquire() + try: self.socket.close() logging.Handler.close(self) + finally: + self.release() def mapPriority(self, levelName): """ @@ -1138,8 +1144,11 @@ class BufferingHandler(logging.Handler): This version just zaps the buffer to empty. """ - with self.lock: + self.acquire() + try: self.buffer = [] + finally: + self.release() def close(self): """ @@ -1189,20 +1198,26 @@ class MemoryHandler(BufferingHandler): The record buffer is also cleared by this operation. """ - with self.lock: + self.acquire() + try: if self.target: for record in self.buffer: self.target.handle(record) self.buffer = [] + finally: + self.release() def close(self): """ Flush, set the target to None and lose the buffer. """ self.flush() - with self.lock: + self.acquire() + try: self.target = None BufferingHandler.close(self) + finally: + self.release() class QueueHandler(logging.Handler): |