New submission from Ilya Kulakov: Currently if one needs lazily resolve event loop depending on where awaitable is being awaited have to pass loop everywhere explicitly. That quickly becomes an unnecessary noise in interfaces of callables.
Consider an example where a coroutine which constructs other awaitables can be executed in arbitrary loop: import asyncio import datetime async def foo_coro(loop): await some_other_coro(loop) async def bar_coro(loop): await asyncio.ensure_future(..., loop=loop) async def baz_coro(loop): await asyncio.gather(foo_coro(loop), bar_coro(loop), loop=loop) loop = asyncio.get_event_loop() loop.run_until_complete(multiple_coros(loop)) loop.close() It would be nice, if all functions that belong to an event loop instance as well as asyncio helpers that accept a loop would set default event loop to one that was passed to these functions. So that the example above could be rewritten as: import asyncio import datetime async def foo_coro(): await some_other_coro() async def bar_coro(): await asyncio.ensure_future(...) async def baz_coro(): await asyncio.gather(foo_coro(), bar_coro()) loop = asyncio.get_event_loop() loop.run_until_complete(multiple_coros()) loop.close() ---------- components: asyncio messages: 264941 nosy: Ilya.Kulakov, gvanrossum, haypo, yselivanov priority: normal severity: normal status: open title: ascynio should provide a policy to address pass-loop-everywhere problem type: enhancement versions: Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26969> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com