]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.7] bpo-36427: Document that PyEval_RestoreThread and PyGILState_Ensure can termina...
authorPablo Galindo <Pablogsal@gmail.com>
Sun, 14 Apr 2019 02:49:17 +0000 (03:49 +0100)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2019 02:49:17 +0000 (03:49 +0100)
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.
(cherry picked from commit fde9b33)

Doc/c-api/init.rst

index a88873bd8f233833309b1be1dfa1e0453e999d47..93fcfe62607828c2e17d56d42bd5df31a43cb704 100644 (file)
@@ -856,6 +856,12 @@ code, or when embedding the Python interpreter:
    *NULL*.  If the lock has been 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)