]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #7403: logging: Fixed possible race condition in lock creation.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 27 Nov 2009 15:36:32 +0000 (15:36 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 27 Nov 2009 15:36:32 +0000 (15:36 +0000)
Lib/logging/__init__.py
Misc/NEWS

index 07f1add37ace601f1bd6c84d1f777efc17b6f691..89bb9f2bbeeea10e3a81f19665758ab0573e2976 100644 (file)
@@ -166,7 +166,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():
     """
@@ -174,9 +177,6 @@ def _acquireLock():
 
     This should be released with _releaseLock().
     """
-    global _lock
-    if (not _lock) and thread:
-        _lock = threading.RLock()
     if _lock:
         _lock.acquire()
 
index 294c53058db77dc4d637cc41b545e1cab7d5edc6..f7264af721dccb5cbbe8f9027e1c30a50c4bf472 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,11 @@ hat's New in Python 2.4.7?
 
 *Release date: XX-XXX-2009*
 
+Library
+-------
+
+- Issue #7403: logging: Fixed possible race condition in lock creation.
+
 
 What's New in Python 2.4.6?
 ===========================