GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — gh-109047: Add PythonFinalizationError exception by vstinner · Pull Request #109809 · python/cpython Conversation
|
|
Ubuntu failed (logs reformatted): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Add PythonFinalizationError. This exception derived from RuntimeError is raised when an operation is blocked during the Python finalization. The following functions now raise PythonFinalizationError, instead of RuntimeError: * _thread.start_new_thread() * os.fork() * os.fork1() * os.forkpty() Morever, _winapi.Overlapped finalizer now logs an unraisable PythonFinalizationError, instead of an unraisable RuntimeError.
261082a to
6d969f3
Compare
|
Perhaps drop the 'Python' prefix (or perhaps change to IntepreterFinalizationError etc) -- as a reader, I'd be confused as to what Python is trying to signify in the name. A |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Python can have multiple interpreters. This exception is when the main interpreter is being finalized. I prefer to document it as "Python finalization". If it's called FinalizationError, you may ask: which finalization? All Python objects have finalizers. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
PrimaryIntepreterFinalizationError? It's perhaps getting a bit silly, though. I still think that 'PythonFinalizationError' is unclear--for example as you noted I would naively think that it would apply to e.g. subinterpreter finalisation, as that's still part of Python. Whilst FinalizationError is generic (as you say), that might not be a bad thing, in case custom object finalisers need to raise errors of a similar nature as here? A |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I prefer the term "Python finalization error".
What is being finalized is not a sub-interpreter or the main interpeter, but in fact, it's the world "Python world": anything related to Python. It's wider than the main interpreter. There are many "global variables" cross-interprereters. Like path configuration (_PyPathConfig_ClearGlobal()), runtime (_PyRuntime_Finalize()), etc. For example, before, Py_Initialize(), it's not possible to create a Python object. Py_Finalize() destroys ("finalizes") all Python objects. When Py_Finalize() completes, it's no longer possible to create new Python objects. That's why https://docs.python.org/dev/c-api/init.html and https://docs.python.org/dev/c-api/init_config.html#init-config are about "Python Initialization". Sadly, https://docs.python.org/dev/c-api/init.html#c.Py_FinalizeEx is not well documented. https://docs.python.org/dev/library/sys.html#sys.is_finalizing mentions "the main Python interpreter". I'm not happy about https://docs.python.org/dev/glossary.html#term-interpreter-shutdown glossary entry. It isn't clear if we are talking about the main interpreter, a sub-interpreter, or "Python". Moreover, there is a competition between "shutting down" and "finalization" terms in the documentation. It should be unified. "Finalization" term is part of the public API: sys.is_finalizing() and Py_Finalize(). "Shutdown" is used in one private API: threading._shutdown(). My notes of Python finalization: https://pythondev.readthedocs.io/finalization.html |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
My fix PR gh-109810 does not strictly need a new exception. So close this PR for now, until someone comes with a more concrete use case which requires adding a new exception. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I created a new PR for this exception: #115352 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.