[issue25074] Bind logger and waninigs modules for asyncio __del__ methods
Andrew Svetlov
report at bugs.python.org
Fri Nov 13 16:49:43 EST 2015
Andrew Svetlov added the comment:
Yes, the approach use hackery shadows for binding global variables on shutdown stage.
The same I've found in subprocess module: see https://github.com/python/cpython/blob/master/Lib/subprocess.py#L1544
The problem is: I want to inform users about unclosed resources.
Printouts like
`TypeError: 'NoneType' object is not callable`
or
`AttributeError: 'NoneType' object has no attribute 'warn'` are too confusing for casual developer.
On shutdown logger and warnings modules may be destroyed at the moment of __del__ call, so `warnings.warn`, `loop.call_exception_handler` etc. are forbidden.
As an option we can add atexit handler to store shutdown flag into loop object (I don't know other way to get info is interpreter in shutdown or not).
According to the flag we can eihter print some short text about non-closed resources or raise proper ResourceWarning along with comprehensive logging with stacktrace if PYTHONASYNCIO is on.
Maybe I've missed something and you can suggest better solution.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25074>
_______________________________________
More information about the Python-bugs-list
mailing list