Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gather() for coroutines #42

Open
lordmauve opened this issue May 14, 2020 · 0 comments
Open

Add gather() for coroutines #42

lordmauve opened this issue May 14, 2020 · 0 comments

Comments

@lordmauve
Copy link
Owner

asyncio.gather() is a function for awaiting several coroutines at once.

Users should be able to write something not dissimilar to

await gather(
    some_coro(),
    another_coro()
)

Perhaps related, the task object returned by clock.coro.run() should have an async def join() so that you can await it finishing:

task = clock.coro.run(...)

await task.join()

This can be used to implement gather:

async def gather(*coros, clock=None):
    clock = clock or get_my_clock()
    tasks = [clock.coro.run(t) for t in coros]
    for t in tasks:
        await t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant