"""
Flushes the stream.
"""
- with self.lock:
+ self.acquire()
+ try:
if self.stream and hasattr(self.stream, "flush"):
self.stream.flush()
+ finally:
+ self.release()
def emit(self, record):
"""
"""
Closes the stream.
"""
- with self.lock:
+ self.acquire()
+ try:
if self.stream:
self.flush()
if hasattr(self.stream, "close"):
self.stream.close()
StreamHandler.close(self)
self.stream = None
+ finally:
+ self.release()
def _open(self):
"""
"""
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):
"""
"""
Closes the socket.
"""
- with self.lock:
+ self.acquire()
+ try:
if self.unixsocket:
self.socket.close()
logging.Handler.close(self)
+ finally:
+ self.release()
def mapPriority(self, levelName):
"""
This version just zaps the buffer to empty.
"""
- with self.lock:
+ self.acquire()
+ try:
self.buffer = []
+ finally:
+ self.release()
def close(self):
"""
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):