]> granicus.if.org Git - python/commitdiff
Issue #7403: logging: Fixed possible race condition in lock creation.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 27 Nov 2009 15:34:35 +0000 (15:34 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 27 Nov 2009 15:34:35 +0000 (15:34 +0000)
Lib/logging/__init__.py
Misc/NEWS

index 39ffae77a8d94801a4f01f6aaff67b19ca5f131d..7850a161a028bf19edd5f6100e697e23777b338f 100644 (file)
@@ -176,7 +176,10 @@ def addLevelName(level, levelName):
 #the lock would already have been acquired - so we need an RLock.
 #The same argument applies to Loggers and Manager.loggerDict.
 #
-_lock = None
+if thread:
+    _lock = threading.RLock()
+else:
+    _lock = None
 
 def _acquireLock():
     """
@@ -184,9 +187,6 @@ def _acquireLock():
 
     This should be released with _releaseLock().
     """
-    global _lock
-    if (not _lock) and thread:
-        _lock = threading.RLock()
     if _lock:
         _lock.acquire()
 
index fff00ddc7acbb51e9e71179085b3679ab0031620..9659f1c39489dd2128bfd58cf47a80c6b01f15e2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,8 @@ Core and builtins
 Library
 -------
 
+- Issue #7403: logging: Fixed possible race condition in lock creation.
+
 - Issue #5068: Fixed the tarfile._BZ2Proxy.read() method that would loop
   forever on incomplete input. That caused tarfile.open() to hang when used
   with mode 'r' or 'r:bz2' and a fileobj argument that contained no data or