diff options
author | Victor Stinner <vstinner@python.org> | 2023-08-18 10:34:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-18 10:34:41 (GMT) |
commit | 3ff5ef2ad3d89c3ccf4e07ac8fdd798267ae6c61 (patch) | |
tree | 4bc924872b423ceb95d0288681ff8ffecc086560 /Doc | |
parent | cc58ec9724772a8d5c4a5c9a6525f9f96e994227 (diff) | |
download | cpython-3ff5ef2ad3d89c3ccf4e07ac8fdd798267ae6c61.zip cpython-3ff5ef2ad3d89c3ccf4e07ac8fdd798267ae6c61.tar.gz cpython-3ff5ef2ad3d89c3ccf4e07ac8fdd798267ae6c61.tar.bz2 |
gh-108014: Add Py_IsFinalizing() function (#108032)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/init.rst | 14 | ||||
-rw-r--r-- | Doc/library/sys.rst | 4 | ||||
-rw-r--r-- | Doc/whatsnew/3.13.rst | 4 |
3 files changed, 17 insertions, 5 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index dd53fe2..60f5c81 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -373,6 +373,14 @@ Initializing and finalizing the interpreter :c:func:`Py_Initialize` is called again. +.. c:function:: int Py_IsFinalizing() + + Return true (non-zero) if the main Python interpreter is + :term:`shutting down <interpreter shutdown>`. Return false (zero) otherwise. + + .. versionadded:: 3.13 + + .. c:function:: int Py_FinalizeEx() Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of @@ -852,7 +860,7 @@ code, or when embedding the Python interpreter: .. 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 + 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. @@ -898,7 +906,7 @@ with sub-interpreters: .. 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 + 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. @@ -1180,7 +1188,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`. .. 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 + 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. diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index b6346ba..da2435a 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1121,8 +1121,8 @@ always available. .. function:: is_finalizing() - Return :const:`True` if the Python interpreter is - :term:`shutting down <interpreter shutdown>`, :const:`False` otherwise. + Return :const:`True` if the main Python interpreter is + :term:`shutting down <interpreter shutdown>`. Return :const:`False` otherwise. .. versionadded:: 3.5 diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 13ae6e5..85aa81b 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -832,6 +832,10 @@ New Features not needed. (Contributed by Victor Stinner in :gh:`106004`.) +* Add :c:func:`Py_IsFinalizing` function: check if the main Python interpreter is + :term:`shutting down <interpreter shutdown>`. + (Contributed by Victor Stinner in :gh:`108014`.) + Porting to Python 3.13 ---------------------- |