Skip to content

gh-108014: Add Py_IsFinalizing() function - #108032

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:is_finalizing
Aug 18, 2023
Merged

gh-108014: Add Py_IsFinalizing() function#108032
vstinner merged 5 commits into
python:mainfrom
vstinner:is_finalizing

Conversation

@vstinner

@vstinnervstinner commented Aug 16, 2023

Copy link
Copy Markdown
Member

@vstinner

Copy link
Copy Markdown
MemberAuthor

@ericsnowcurrently: Oh, that's a "feature" PR, so I will need a formal approval to merge it :-)

@vstinner

Copy link
Copy Markdown
MemberAuthor

I prepared python/pythoncapi-compat#66 to add the function to the pythoncapi-compat project.

@gvanrossum
gvanrossum removed their request for review August 16, 2023 18:05
Comment threadDoc/c-api/init.rst Outdated
Comment on lines +378 to +379
Return non-zero if the Python interpreter is :term:`shutting down
<interpreter shutdown>`, return 0 otherwise.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 NULL to mean the current one (or main)?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The 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.

Comment threadDoc/c-api/init.rst
Comment threadDoc/c-api/init.rst Outdated
@kumaraditya303
kumaraditya303 removed their request for review August 17, 2023 06:08

@serhiy-storchakaserhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment threadDoc/c-api/init.rst
Comment threadDoc/whatsnew/3.13.rst Outdated
Comment threadMisc/NEWS.d/next/C API/2023-08-16-17-16-19.gh-issue-108014.wXN3CF.rst Outdated
vstinnerand others added 2 commits August 17, 2023 22:01
…3CF.rst
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@vstinner
vstinner merged commit 3ff5ef2 into python:mainAug 18, 2023
@vstinner
vstinner deleted the is_finalizing branch August 18, 2023 10:34
@vstinner

Copy link
Copy Markdown
MemberAuthor

Thanks for the review @ericsnowcurrently and @serhiy-storchaka!

@vstinner

Copy link
Copy Markdown
MemberAuthor

Follow-up: @wjakob asks to add this new function to the limited C API version 3.13.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@vstinner@ericsnowcurrently@serhiy-storchaka@bedevere-bot