How to use context.run(asynchronous=True) for many tasks

Open
#892 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
documentation

Research direction

Start with the Promise.join API documentation linked in the issue and the context.run(asynchronous=True) entry point. Clarify how several asynchronous runs can be waited on together, including completion and error behavior, and add a concise usage example so the documentation answers the five-task scenario.

Written by the indexing model from the issue text.

Description

Hi, a usage question as the docs are quite lite on this topic.

If I want to make 5 context.run() calls concurrently but I don't want to complete execution of my function until they have all finished, is there something more elegant than this:

class AggregateError(Exception): 
    pass

running = [context.run(foo, async=True), context.run(bar, async=True), context.run(baz, async=True)]

while running:
    for promise, index in enumerate(running[:]):
        ....
Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.