gh-87135: threading.Lock: Raise rather than hang on Python finalization (GH-135991)

After Python finalization gets to the point where no other thread
can attach thread state, attempting to acquire a Python lock must hang.
Raise PythonFinalizationError instead of hanging.
This commit is contained in:
Petr Viktorin 2025-07-01 10:57:42 +02:00 committed by GitHub
parent 845263adc6
commit fe119a0817
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 97 additions and 5 deletions

View file

@ -0,0 +1,3 @@
Acquiring a :class:`threading.Lock` or :class:`threading.RLock` at interpreter
shutdown will raise :exc:`PythonFinalizationError` if Python can determine
that it would otherwise deadlock.