]> granicus.if.org Git - python/commitdiff
Fix added for recent changes in non-threading environments.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 23 Feb 2012 20:49:08 +0000 (20:49 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 23 Feb 2012 20:49:08 +0000 (20:49 +0000)
Lib/logging/__init__.py
Lib/logging/handlers.py

index b4c823d36d9d4072eaebb8ff45146af8d389ef72..4191b222a6c4542b94e58d581c18ce6e93c0bdf9 100644 (file)
@@ -917,9 +917,12 @@ class StreamHandler(Handler):
         """
         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):
         """
@@ -970,13 +973,16 @@ class FileHandler(StreamHandler):
         """
         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):
         """
index 9fea2e8bf37cfb11d68947d6dcaaa2b69acd158e..708edc51ac76184668846ebed8d7151944df6b68 100644 (file)
@@ -553,11 +553,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):
     """
@@ -752,10 +755,13 @@ class SysLogHandler(logging.Handler):
         """
         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):
         """
@@ -1096,8 +1102,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):
         """
@@ -1147,20 +1156,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):