`__del__` behavior on interpreter shutdown
See original GitHub issueWhen finishing program execution, python does not guarantee the order in which objects are destroyed.
Calls inside a __del__
method calling other objects or modules are not guaranteed to be correctly executed.
https://github.com/cupy/cupy/blob/master/cupy/cuda/stream.pyx#L185
It is known to fail because runtime
module is already unloaded when __del__
is called.
https://docs.python.org/3/reference/datamodel.html#object.__del__
This can affect behavior on RAII pattern.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
starting a thread in __del__ hangs at interpreter shutdown
It's due to creating the stdout/stderr worker threads from the __del__ finalizer while the interpreter is shutting down.
Read more >[Python-Dev] Adding a scarier warning to object.__del__?
Hey everyone,. I just encountered yet another reason to beware of __del__: when it's called during interpreter shutdown, for reasons which are ...
Read more >Where is Python's shutdown procedure setting module globals ...
CPython has a strange behaviour where it sets modules to None during shutdown. This screws up error logging during shutdown of some ...
Read more >A Normal Accident In Python and mod_wsgi
During interpreter shutdown, None is somehow being called as a function. I'm no expert on Python's shutdown sequence, but I've never heard ...
Read more >The 10 Most Common Mistakes That Python Developers Make
That way, when your program is finished executing (when exiting normally, that is), your registered handlers are kicked off before the interpreter is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Installed manually
Conda flags
Pyenv python 3.7.3 flags (python3-config --cflags)
We just found that if we install python with pyenv, then it breaks just with
python -c 'import cupy; stream = cupy.cuda.Stream()'
Credit goes to @niboshi