dispatchrun / dispatch-py

Python package to develop applications with Dispatch.
https://pypi.org/project/dispatch-py/
Apache License 2.0
54 stars 3 forks source link

Add additional concurrency primitives #88

Closed chriso closed 6 months ago

chriso commented 7 months ago

The SDK provides a gather function that concurrently runs zero or more awaitables, and blocks until all awaitables return successfully or any awaitable raises.

async def gather(*awaitables: Awaitable[Any]) -> list[Any]: ...

The name was chosen to match the asyncio function that has the same behavior. See https://docs.python.org/3/library/asyncio-task.html#running-tasks-concurrently.

Other languages provide a more complete set of concurrency/composition primitives. For example, JavaScript provides Promise.all, Promise.any and Promise.race:

We should consider adding any and race, and aliasing gather as all.