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: v3.2a1~2115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03f6c11f07f7f7163186c7f8cb9da086ba703162;p=python Issue #7403: Fixed possible race condition in lock creation. --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 6ff2216a26..487a22593d 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -199,7 +199,11 @@ 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(): """ @@ -207,9 +211,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 724c97eeb3..1cff0b7aee 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -140,6 +140,8 @@ C-API 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.