-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Add a function to know about interpreter shutdown #66885
Comments
I propose to add a new function sys.shutting_down() (name debatable) returning True if the interpreter is currently shutting down. This would be a function so that you can bind it and avoid having it wiped at shutdown :-) |
For the issue bpo-22599, I wrote a patch but then I removed my patch and reverted my changed... Here is a new patch which implements why I already wrote: add a new sys._is_finalizing() function, with a unit test.
The name sounds like a function to shut down the computer or exit Python. I don't like _is_finalizing() name neither :-) My patch uses a private function which is CPython specific. Does it make sense to add a public function instead? Is it possible to implement it in any Python implementation (PyPy, IronPython, Jython, etC.)? I guess that the most dummy implementation is to always return False (Python is always running. |
Are there other special interpreter states about which it would by helpful to |
I would like it to be public. It can be useful in __del__ methods and the like. |
|
I'm +0 for is_finalizing. There is a typo in the docstring. |
An indirect way how to know about interpreter shutdown -- test existing of the path attribute in sys (bpo-20603). |
After solving this issue we should reconsider the traceback_ignore_linecache_error.patch patch in bpo-22599. |
I reposted the patch in this issue since I just closed the issue bpo-22599. |
Here is a patch with docs. |
is_finalizing2.patch looks good to me. |
Before committing the patch it will be good to find places in the code which will benefit from this function. And please don't forget to fix a typo in the docstring. |
The traceback and/or the linecache is a first good candidate to use this new function. We may patch more functions later if needed, I don't think that we need to address all issues right now. |
New changeset 7f3695701724 by Antoine Pitrou in branch 'default': |
Using the function in the stdlib can be done separately. I fixed the typo in the docstring. Thanks! |
Is there an open issue for that? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: