Skip to content

Commit ec1cced

Browse files
committed
Issue python#7403: logging: Fixed possible race condition in lock creation.
1 parent fb2e7a5 commit ec1cced

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Lib/logging/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ def addLevelName(level, levelName):
166166
#the lock would already have been acquired - so we need an RLock.
167167
#The same argument applies to Loggers and Manager.loggerDict.
168168
#
169-
_lock = None
169+
if thread:
170+
_lock = threading.RLock()
171+
else:
172+
_lock = None
170173

171174
def _acquireLock():
172175
"""
173176
Acquire the module-level lock for serializing access to shared data.
174177
175178
This should be released with _releaseLock().
176179
"""
177-
global _lock
178-
if (not _lock) and thread:
179-
_lock = threading.RLock()
180180
if _lock:
181181
_lock.acquire()
182182

Misc/NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ hat's New in Python 2.4.7?
99

1010
*Release date: XX-XXX-2009*
1111

12+
Library
13+
-------
14+
15+
- Issue #7403: logging: Fixed possible race condition in lock creation.
16+
1217

1318
What's New in Python 2.4.6?
1419
===========================

0 commit comments

Comments
 (0)