-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-108014: Add Py_IsFinalizing() function #108032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e03b437
f769755
9bd258f
fe6216c
fa76703
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,6 +373,14 @@ Initializing and finalizing the interpreter | |
:c:func:`Py_Initialize` is called again. | ||
|
||
|
||
.. c:function:: int Py_IsFinalizing() | ||
|
||
Return non-zero if the Python interpreter is :term:`shutting down | ||
<interpreter shutdown>`, return 0 otherwise. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this referring to the runtime (AKA main interpreter) or to the current interpreter? I'd expect it to be the current interpreter. Would it make sense to explicitly pass an interpreter and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied the documentation of the sys.is_finalizing() function. If you want a different feature (pass an interpreter), I would prefer to have a different function. It's set by Py_Finalize() which finalizes the main interpreter: other sub-interpreters should be deleted before explicitly, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the doc to specify that we are talking about the main interpreter.
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. 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. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add :c:func:`Py_IsFinalizing` function: check if the Python interpreter is | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:term:`shutting down <interpreter shutdown>`. Patch by Victor Stinner. |
Uh oh!
There was an error while loading. Please reload this page.