This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ilya.Kulakov
Recipients Ilya.Kulakov, gvanrossum, vstinner, yselivanov
Date 2016-05-06.06:52:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1462517538.3.0.176027238089.issue26969@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2016-05-06 06:52:18Ilya.Kulakovsetrecipients: + Ilya.Kulakov, gvanrossum, vstinner, yselivanov
2016-05-06 06:52:18Ilya.Kulakovsetmessageid: <1462517538.3.0.176027238089.issue26969@psf.upfronthosting.co.za>
2016-05-06 06:52:18Ilya.Kulakovlinkissue26969 messages
2016-05-06 06:52:17Ilya.Kulakovcreate