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 additional concurrency primitives #88

Closed
chriso opened this issue Feb 23, 2024 · 0 comments · Fixed by #131
Closed

Add additional concurrency primitives #88

chriso opened this issue Feb 23, 2024 · 0 comments · Fixed by #131
Assignees
Labels
enhancement New feature or request

Comments

@chriso
Copy link
Contributor

chriso commented Feb 23, 2024

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:

  • all: returns when all awaitables return successfully, or any awaitable raises (like gather)
  • any: returns when any awaitable returns successfully, or all awaitables raise
  • race: returns when any awaitable returns or raises

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

@chriso chriso added the enhancement New feature or request label Feb 23, 2024
@Pryz Pryz moved this to TODO in Dispatch Public Roadmap Mar 12, 2024
@chriso chriso self-assigned this Mar 21, 2024
@github-project-automation github-project-automation bot moved this from TODO to Developer preview in Dispatch Public Roadmap Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Developer preview
Development

Successfully merging a pull request may close this issue.

1 participant