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

index 3fe03cdeb63e1680ab1de6b9dc4f613d0edaa5cb..03c67b020471d3528fd93bdd8ce226c5f07ff03f 100644 (file)
@@ -186,7 +186,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():
     """
@@ -194,9 +197,6 @@ def _acquireLock():
 
     This should be released with _releaseLock().
     """
-    global _lock
-    if (not _lock) and thread:
-        _lock = threading.RLock()
     if _lock:
         _lock.acquire()
 
index 746e3422dd7d0f1ed8f6a811a332795a8078f8b0..ca36adcdb7965a563a95bfff42cb0ccd0eac8f8a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -33,6 +33,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #7403: logging: Fixed possible race condition in lock creation.
+
 - Issue #7341: Close the internal file object in the TarFile constructor in
   case of an error.