mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #21149: Improved thread-safety in logging cleanup during interpreter shutdown.
This commit is contained in:
parent
b30b34c1aa
commit
156307bfd6
2 changed files with 12 additions and 8 deletions
|
|
@ -711,16 +711,17 @@ def _removeHandlerRef(wr):
|
||||||
Remove a handler reference from the internal cleanup list.
|
Remove a handler reference from the internal cleanup list.
|
||||||
"""
|
"""
|
||||||
# This function can be called during module teardown, when globals are
|
# This function can be called during module teardown, when globals are
|
||||||
# set to None. If _acquireLock is None, assume this is the case and do
|
# set to None. It can also be called from another thread. So we need to
|
||||||
# nothing.
|
# pre-emptively grab the necessary globals and check if they're None,
|
||||||
if (_acquireLock is not None and _handlerList is not None and
|
# to prevent race conditions and failures during interpreter shutdown.
|
||||||
_releaseLock is not None):
|
acquire, release, handlers = _acquireLock, _releaseLock, _handlerList
|
||||||
_acquireLock()
|
if acquire and release and handlers:
|
||||||
|
acquire()
|
||||||
try:
|
try:
|
||||||
if wr in _handlerList:
|
if wr in handlers:
|
||||||
_handlerList.remove(wr)
|
handlers.remove(wr)
|
||||||
finally:
|
finally:
|
||||||
_releaseLock()
|
release()
|
||||||
|
|
||||||
def _addHandlerRef(handler):
|
def _addHandlerRef(handler):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #21149: Improved thread-safety in logging cleanup during interpreter
|
||||||
|
shutdown. Thanks to Devin Jeanpierre for the patch.
|
||||||
|
|
||||||
- Issue #20145: `assertRaisesRegex` and `assertWarnsRegex` now raise a
|
- Issue #20145: `assertRaisesRegex` and `assertWarnsRegex` now raise a
|
||||||
TypeError if the second argument is not a string or compiled regex.
|
TypeError if the second argument is not a string or compiled regex.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue