You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Update logging library module lock to use context manager to acquire/release lock. #109461
Current implementation relies on both _acquireLock() and _releaseLock() being called, otherwise a lock may never be released:
def_acquireLock():
""" Acquire the module-level lock for serializing access to shared data. This should be released with _releaseLock(). """if_lock:
try:
_lock.acquire()
exceptBaseException:
_lock.release()
raisedef_releaseLock():
""" Release the module-level lock acquired by calling _acquireLock(). """if_lock:
_lock.release()
The majority of usages of _acquireLock() manually add a try/except/finally block to ensure that the lock is released if an exception is thrown. Some usages of _acquireLock() have no safety.
The proposal is to alter the usage of _acquireLock() to be a context manager that deals with acquiring and releasing automatically rather than requiring try/except/finally blocks to be used anywhere the function is called.
For example,
usage before:
_acquireLock()
try:
...
finally:
_releaseLock()
proposed usage:
with_acquireLock():
...
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge remote-tracking branch 'origin/pythongh-109461-update-logging-l…
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge remote-tracking branch 'origin/pythongh-109461-update-logging-l…
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge remote-tracking branch 'origin/pythongh-109461-update-logging-l…
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge remote-tracking branch 'origin/pythongh-109461-update-logging-l…
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
Merge branch 'main' into pythongh-109461-update-logging-lock-acquisition
gh-109461: Update logging module lock to use context manager (#109462)
pythongh-109461: Update logging module lock to use context manager (p…
tests: Update private logging API usage for Python 3.13
pythongh-109461: Update logging module lock to use context manager (p…