summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-04-13 16:23:24 (GMT)
committerGitHub <noreply@github.com>2019-04-13 16:23:24 (GMT)
commitfde9b33dfeedd4a4ed723b12d2330979dc684760 (patch)
treec59bb8ffcfff3374eee09b4b9b5c969bf19fcebc /Doc/c-api
parent46544f69bff1c3c4173d461be35993ca0109f622 (diff)
downloadcpython-fde9b33dfeedd4a4ed723b12d2330979dc684760.zip
cpython-fde9b33dfeedd4a4ed723b12d2330979dc684760.tar.gz
cpython-fde9b33dfeedd4a4ed723b12d2330979dc684760.tar.bz2
bpo-36427: Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread (GH-12541)
Calling these function from a thread when the runtime is finalizing will terminate the thread, even if the thread was not created by Python. Users can use _Py_IsFinalizing or sys.is_finalizing to check if the interpreter is in the process of being finalized before calling this function to avoid unwanted termination.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/init.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index 7c1f0ff..7ef1122 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -856,6 +856,12 @@ code, or when embedding the Python interpreter:
created, the current thread must not have acquired it, otherwise deadlock
ensues.
+ .. note::
+ Calling this function from a thread when the runtime is finalizing
+ will terminate the thread, even if the thread was not created by Python.
+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
+ check if the interpreter is in process of being finalized before calling
+ this function to avoid unwanted termination.
.. c:function:: PyThreadState* PyThreadState_Get()
@@ -903,6 +909,12 @@ with sub-interpreters:
When the function returns, the current thread will hold the GIL and be able
to call arbitrary Python code. Failure is a fatal error.
+ .. note::
+ Calling this function from a thread when the runtime is finalizing
+ will terminate the thread, even if the thread was not created by Python.
+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
+ check if the interpreter is in process of being finalized before calling
+ this function to avoid unwanted termination.
.. c:function:: void PyGILState_Release(PyGILState_STATE)