summaryrefslogtreecommitdiffstats
path: root/Lib/logging/handlers.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r--Lib/logging/handlers.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index d4f8aef..02a5fc1 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -627,9 +627,10 @@ class SocketHandler(logging.Handler):
"""
self.acquire()
try:
- if self.sock:
- self.sock.close()
+ sock = self.sock
+ if sock:
self.sock = None
+ sock.close()
logging.Handler.close(self)
finally:
self.release()
@@ -1213,8 +1214,10 @@ class BufferingHandler(logging.Handler):
This version just flushes and chains to the parent class' close().
"""
- self.flush()
- logging.Handler.close(self)
+ try:
+ self.flush()
+ finally:
+ logging.Handler.close(self)
class MemoryHandler(BufferingHandler):
"""
@@ -1268,13 +1271,15 @@ class MemoryHandler(BufferingHandler):
"""
Flush, set the target to None and lose the buffer.
"""
- self.flush()
- self.acquire()
try:
- self.target = None
- BufferingHandler.close(self)
+ self.flush()
finally:
- self.release()
+ self.acquire()
+ try:
+ self.target = None
+ BufferingHandler.close(self)
+ finally:
+ self.release()
class QueueHandler(logging.Handler):