[Async-sig] PEP: asynchronous generators

Andrew Svetlov andrew.svetlov at gmail.com
Sat Jul 30 08:06:31 EDT 2016


It may wait forever in case of malformed generator implementation.

On Sat, Jul 30, 2016 at 2:04 PM Герасимов Михаил <Gerasimov-M-N at yandex.ru>
wrote:

> Looks like to be sure everything finished correctly, we'll need to do
> something like this every time:
>
> loop.run_until_complete(main())
>
> pending = asyncio.Task.all_tasks()
> loop.run_until_complete(asyncio.gather(*pending))
>
> loop.close()
>
> Bad thing here I think is that we can't split manually created tasks (wich
> warnings we might would like to get to complete this tasks in other places)
> and AG's close tasks wich we can't complete other place then here.
>
> Don't you like idea to await all AG's close tasks done right before event
> loop is closed? I mean to modify event loop this way:
>
> # asyncio/base_events.py
>
> class BaseEventLoop:
>     def _finalize_asyncgen(self, gen):
>         task = self.create_task(gen.aclose())
>         self._close_tasks.append(task)
>
>     def close():
>         self.run_until_complete(
>             asyncio.gather(*self._close_tasks)
>         )
>         ...
>
> In this case user would be able to use async generators without worring he
> will get warning.
>
>  _______________________________________________
> Async-sig mailing list
> Async-sig at python.org
> https://mail.python.org/mailman/listinfo/async-sig
> Code of Conduct: https://www.python.org/psf/codeofconduct/

-- 
Thanks,
Andrew Svetlov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/async-sig/attachments/20160730/5553ca4b/attachment.html>


More information about the Async-sig mailing list