]> 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 667a3a5a4d331be8d43bb0bd3eba6406caeb1e25..3f8cf05b12d7132a2c32a7f967b541705f1b3e0d 100644 (file)
@@ -202,7 +202,10 @@ def _checkLevel(level):
 #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():
     """
@@ -210,9 +213,6 @@ def _acquireLock():
 
     This should be released with _releaseLock().
     """
-    global _lock
-    if (not _lock) and thread:
-        _lock = threading.RLock()
     if _lock:
         _lock.acquire()
 
index 449cc2b3af542f995ee8e4c5650f58666f11f8f2..e915e29536de2dbf61d3fe1e26dc524801e3994b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -483,6 +483,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #7403: logging: Fixed possible race condition in lock creation.
+
 - Issue #6845: Add restart support for binary upload in ftplib.  The
   `storbinary()` method of FTP and FTP_TLS objects gains an optional `rest`
   argument.  Patch by Pablo Mouzo.