agronholm / agronholm/anyio

Extend concurrency helper utilities to work with async iterables for arguments

Aperta
#1,310 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
2.5k
Fork
260
Merge medio
2g 8h
PR unite (30g)
19

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

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend, developer-experience
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Da chiarire
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.