Extend concurrency helper utilities to work with async iterables for arguments
- Langage dominant
- Python
- Étoiles
- 2.5k
- Forks
- 260
- Merge moyen
- 2 j 8 h
- PR mergées (30 j)
- 19
Description
### Things to check first
- [x] I have searched the existing issues and didn't find my feature already requested there
### Feature description
Just a thought, as I'm not sure this is worth the complexity or API change.
Currently, you can't:
- Pass an async iterable to `amap()`'s `args` parameter
- Spread an async generator to use in `gather()`
### Use case
I find myself often writing code like this:
```python
async with create_task_group() as tg:
async for foo in get_foo():
tg.start_soon(process_foo, foo)
```
At first, this looks like what the concurrency utilities should help with, but I don't think it's currently possible.
You'd need to do this to use `amap()`:
```python
await amap(process_foo, [foo async for foo in get_foo()])
```
Which defeats the point of `get_foo()` being async.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Read the amap() and gather() implementations and their current argument handling first. Check the existing tests for both utilities and define the supported async-iterable behavior before changing the API; done means async iterables can supply amap() arguments and async generators can be consumed by gather() without materializing them.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend, developer-experience
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Active
- Clarté
- À clarifier
- Accessibilité débutants
- 48/100