From: Vinay Sajip Date: Fri, 27 Nov 2009 14:03:36 +0000 (+0000) Subject: Issue #7403: Fixed possible race condition in lock creation. X-Git-Tag: v2.7a1~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=01801d1f088ca95c06a976dcd822d390d74b47d2;p=thirdparty%2FPython%2Fcpython.git Issue #7403: Fixed possible race condition in lock creation. --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 667a3a5a4d33..3f8cf05b12d7 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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() diff --git a/Misc/NEWS b/Misc/NEWS index 449cc2b3af54..e915e29536de 100644 --- 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.