Andrew Svetlov added the comment:

> You should try to implement something in aiohttp or even in the application 
> to cleanup objects at exit. For example, it's probably wrong if you still 
> have tasks when the event loop is closed. Especially if tasks are still 
> pending.

The problem is for client API. For server I have more control and  implemented 
checks like you suggest.

For for client lazy user writes floppy code like:

    client = aiohttp.ClientSession()
    resp = yield from client.get(url)
    text = yield from resp.text()

Client is closed by GC, at the moment is not determined is loop has been closed 
or not (GC releases object in non-determenistic way).

So without changes I just cannot use `loop.call_exception_handler()` in 
`__del__` methods.

It's not only aiohttp issue but we should get rid of `call_exception_handler()` 
reports in asyncio itself for the same reason. 

We have `logger` and `warnings` modules usage e.g. in asyncio transports, it's 
not safe if transport is not closed properly before interpreter shutdown.

`subprecess` module has tricks for proper destruction like I've used in my 
patch.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25074>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to