mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
845263adc6
commit
fe119a0817
6 changed files with 97 additions and 5 deletions
|
@ -429,7 +429,9 @@ The following exceptions are the exceptions that are usually raised.
|
|||
|
||||
* Creating a new Python thread.
|
||||
* :meth:`Joining <threading.Thread.join>` a running daemon thread.
|
||||
* :func:`os.fork`.
|
||||
* :func:`os.fork`,
|
||||
* acquiring a lock such as :class:`threading.Lock`, when it is known that
|
||||
the operation would otherwise deadlock.
|
||||
|
||||
See also the :func:`sys.is_finalizing` function.
|
||||
|
||||
|
@ -440,6 +442,11 @@ The following exceptions are the exceptions that are usually raised.
|
|||
|
||||
:meth:`threading.Thread.join` can now raise this exception.
|
||||
|
||||
.. versionchanged:: next
|
||||
|
||||
This exception may be raised when acquiring :meth:`threading.Lock`
|
||||
or :meth:`threading.RLock`.
|
||||
|
||||
.. exception:: RecursionError
|
||||
|
||||
This exception is derived from :exc:`RuntimeError`. It is raised when the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue