ethereum / ethereum/async-service
New API: manager.wait_child_tasks_complete()
- Dominant language
- Python
- Stars
- 10
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
## What was wrong?
This is heavily inspired by and related to #66
Currently the standard pattern we typically use in many places is:
```python
def run(self):
... do sub-task things
await self.manager.wait_finished()
```
This pattern doesn't have to be present in the `run` method, but it is most commonly found here.
In many cases, we may actually not want to wait indefinitely, but rather, until all of the child tasks are finished.
## How can it be fixed?
Since the services manage a DAG for all tasks, we should be able to implement a method that blocks until all child tasks have completed. Considering the case where a service runs child tasks or services and then has a natural exit condition, the above pattern would likely turn into:
```python
def run(self):
... do sub-task things
await self.manager.wait_all_child_tasks_complete()
```
Once #66 has been addressed, this pattern would not be explicitly required, I believe it would still impove the UX of the library since it would expose a more refined API for waiting for the actual condition that the code intends to block until rather than having to resort to an API that blocks indefinitely absent a call to `manager.cancel()`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the related issue #66 and tracing the manager's existing wait_finished() behavior and child-task lifecycle. Identify how the service's DAG tracks child completion. Done means the public manager API waits for all child tasks to complete without requiring indefinite waiting or cancellation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100