[Python-checkins] [3.7] bpo-36427: Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread (GH-12541) (GH-12820)

Pablo Galindo webhook-mailer at python.org
Sat Apr 13 22:49:33 EDT 2019


https://github.com/python/cpython/commit/7723d0545c3369e1b2601b207c250c70ce90b75e
commit: 7723d0545c3369e1b2601b207c250c70ce90b75e
branch: 3.7
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019年04月14日T03:49:17+01:00
summary:
[3.7] bpo-36427: Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread (GH-12541) (GH-12820)
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)
files:
M Doc/c-api/init.rst
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index a88873bd8f23..93fcfe626078 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -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)
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /