[Python-checkins] r76554 - in python/branches/release25-maint: Lib/logging/__init__.py Misc/NEWS

vinay.sajip python-checkins at python.org
Fri Nov 27 16:34:35 CET 2009


Author: vinay.sajip
Date: Fri Nov 27 16:34:35 2009
New Revision: 76554

Log:
Issue #7403: logging: Fixed possible race condition in lock creation.

Modified:
   python/branches/release25-maint/Lib/logging/__init__.py
   python/branches/release25-maint/Misc/NEWS

Modified: python/branches/release25-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release25-maint/Lib/logging/__init__.py	(original)
+++ python/branches/release25-maint/Lib/logging/__init__.py	Fri Nov 27 16:34:35 2009
@@ -176,7 +176,10 @@
 #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 @@
 
     This should be released with _releaseLock().
     """
-    global _lock
-    if (not _lock) and thread:
-        _lock = threading.RLock()
     if _lock:
         _lock.acquire()
 

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Fri Nov 27 16:34:35 2009
@@ -18,6 +18,8 @@
 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


More information about the Python-checkins mailing list