@@ -863,6 +863,7 @@ code, or when embedding the Python interpreter:
863863 check if the interpreter is in process of being finalized before calling
864864 this function to avoid unwanted termination.
865865
866+
866867.. c:function:: PyThreadState* PyThreadState_Get()
867868
868869 Return the current thread state. The global interpreter lock must be held.
@@ -1080,9 +1081,27 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
10801081 *tstate *, which should not be *NULL *. The lock must have been created earlier.
10811082 If this thread already has the lock, deadlock ensues.
10821083
1084+ .. note ::
1085+ Calling this function from a thread when the runtime is finalizing
1086+ will terminate the thread, even if the thread was not created by Python.
1087+ You can use :c:func: `_Py_IsFinalizing ` or :func: `sys.is_finalizing ` to
1088+ check if the interpreter is in process of being finalized before calling
1089+ this function to avoid unwanted termination.
1090+
1091+ .. versionchanged :: 3.8
1092+ Updated to be consistent with :c:func: `PyEval_RestoreThread `,
1093+ :c:func: `Py_END_ALLOW_THREADS `, and :c:func: `PyGILState_Ensure `,
1094+ and terminate the current thread if called while the interpreter is finalizing.
1095+
10831096 :c:func: `PyEval_RestoreThread ` is a higher-level function which is always
10841097 available (even when threads have not been initialized).
10851098
1099+ .. note::
1100+ Calling this function from a thread when the runtime is finalizing
1101+ will terminate the thread, even if the thread was not created by Python.
1102+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
1103+ check if the interpreter is in process of being finalized before calling
1104+ this function to avoid unwanted termination.
10861105
10871106.. c:function:: void PyEval_ReleaseThread(PyThreadState *tstate)
10881107
@@ -1106,6 +1125,18 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
11061125 :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread`
11071126 instead.
11081127
1128+ .. note::
1129+ Calling this function from a thread when the runtime is finalizing
1130+ will terminate the thread, even if the thread was not created by Python.
1131+ You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
1132+ check if the interpreter is in process of being finalized before calling
1133+ this function to avoid unwanted termination.
1134+
1135+ .. versionchanged:: 3.8
1136+ Updated to be consistent with :c:func:`PyEval_RestoreThread`,
1137+ :c:func:`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`,
1138+ and terminate the current thread if called while the interpreter is finalizing.
1139+
11091140
11101141.. c:function:: void PyEval_ReleaseLock()
11111142
0 commit comments