[Async-sig] PEP: asynchronous generators

Герасимов Михаил Gerasimov-M-N at yandex.ru
Sat Jul 30 11:08:47 EDT 2016


> When you have `await task` line you probably know what task it is, you 
> can debug and fix it.
>
> But hanging on `loop.close()` because some unknown task hangs looks 
> very confusing.
> The approach gives no clue for what task is malformed.
>
> Users will blame that `loop.close()` hangs forever without any reason 
> or additional information.

ok, regardless placing this code inside `loop.close()` is there any 
alternative to sure async generators inside `main()` are closed?

    loop.run_until_complete(main())

    pending = asyncio.Task.all_tasks()
    loop.run_until_complete(asyncio.gather(*pending))

    loop.close()

Currently, I just don't see any other way to use some async generator 
(that needs some time to be closed) without getting warning.

In case malformed generator is unwantedbehaviour may be it'll be ok to 
show warning in debug mode if some close task isn't finished after some 
timeout?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/async-sig/attachments/20160730/b93134b7/attachment.html>


More information about the Async-sig mailing list