Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 926525d

Browse files
committed
bpo-36427: Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread
1 parent 9a0000d commit 926525d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Doc/c-api/init.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,12 @@ code, or when embedding the Python interpreter:
855855
created, the current thread must not have acquired it, otherwise deadlock
856856
ensues.
857857
858+
.. warning::
859+
Calling this function from a thread when the interpreter is finalizing
860+
will terminate the thread, even if the thread was not created by Python.
861+
You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
862+
check if the interpreter is in process of being finalized before calling
863+
this function to avoid unwanted termination.
858864
859865
.. c:function:: PyThreadState* PyThreadState_Get()
860866
@@ -902,6 +908,12 @@ with sub-interpreters:
902908
When the function returns, the current thread will hold the GIL and be able
903909
to call arbitrary Python code. Failure is a fatal error.
904910
911+
.. warning::
912+
Calling this function from a thread when the interpreter is finalizing
913+
will terminate the thread, even if the thread was not created by Python.
914+
You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
915+
check if the interpreter is in process of being finalized before calling
916+
this function to avoid unwanted termination.
905917
906918
.. c:function:: void PyGILState_Release(PyGILState_STATE)
907919

0 commit comments

Comments
 (0)