Extend concurrency helper utilities to work with async iterables for arguments
- Lingua principale
- Python
- Stelle
- 2.5k
- Fork
- 260
- Merge medio
- 1g 8h
- PR unite (30g)
- 17
Descrizione
### 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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.