googleapis / googleapis/python-genai

Expose a transport-level `cancel`/`close` handle on async streaming responses (so they can be cancelled from another task)

Aperta
#2,425 1 commento 0 reazioni 1 assegnatario Rivendicata da @Venkaiahbabuneelam Vedi su GitHub
priority: p3 type: feature request
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 11h
PR unite (30g)
40

Descrizione

While working on https://github.com/pydantic/pydantic-ai/issues/1524 I hit: generate_content_stream only exposes the generator, so cancelling it from another task while we're iterating raises `RuntimeError`: `aclose(): asynchronous generator is already running`.

**Describe the solution you'd like**
A transport handler we could close with or cancel with would be great

**Describe alternatives you've considered**
There are some things we could do to maybe mimic this but given that most SDKs have this it would be nice if `genai` did too

**Additional context**
I have just added a small warning for now.
https://pydantic.dev/docs/ai/models/google/#streaming-cancellation

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.