cpython
cpython copied to clipboard
gh-87135: threading.Lock: Raise rather than hang on Python finalization
After Python finalization gets to the point where no other thread can attach thread state, attempting to acquire a Python lock will hang. Raise PythonFinalizationError instead of hanging.
@colesbury, does this look maintainable (and correct) to you?
- Issue: gh-87135
Tests / Windows (free-threading) / Build and test (arm64) (pull_request) Tests / Windows (free-threading) / Build and test (x64) (pull_request)
There is a suspicious error when running test.test_multiprocessing_spawn.test_processes:
Assertion failed: !PyErr_Occurred(), file D:\a\cpython\cpython\Python\specialize.c, line 740
Fatal Python error: Aborted
<Cannot show all threads while the GIL is disabled>
Stack (most recent call first):
File "D:\a\cpython\cpython\Lib\logging\__init__.py", line 891 in _removeHandlerRef
Current thread's C stack trace (most recent call first):
<cannot get C stack on this system>