Message409847
This doesn't look like a bug to me and is documented behavior:
https://docs.python.org/3/reference/datamodel.html#object.__del__
Check this paragraph:
Warning Due to the precarious circumstances under which __del__() methods are invoked, exceptions that occur during their execution are ignored, and a warning is printed to sys.stderr instead. In particular:
__del__() can be invoked when arbitrary code is being executed, including from any arbitrary thread. If __del__() needs to take a lock or invoke any other blocking resource, it may deadlock as the resource may already be taken by the code that gets interrupted to execute __del__().
__del__() can be executed during interpreter shutdown. As a consequence, the global variables it needs to access (including other modules) may already have been deleted or set to None. Python guarantees that globals whose name begins with a single underscore are deleted from their module before other globals are deleted; if no other references to such globals exist, this may help in assuring that imported modules are still available at the time when the __del__() method is called.
----
Here, the object __del__ should take s strong reference to whatever is going to use to ensure is available when needed. Indeed, the standard library does this regularly, for example:
https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Lib/asyncio/windows_utils.py#L110
I am closing it as "not a bug" but feel free to reopen if we think we missed something or I misinterpret the bug report. |
|
Date |
User |
Action |
Args |
2022-01-06 13:55:40 | pablogsal | set | recipients:
+ pablogsal, piro, Dennis Sweeney, cvickery |
2022-01-06 13:55:40 | pablogsal | set | messageid: <1641477340.91.0.422061342737.issue46256@roundup.psfhosted.org> |
2022-01-06 13:55:40 | pablogsal | link | issue46256 messages |
2022-01-06 13:55:40 | pablogsal | create | |
|