While working on pydantic/pydantic-ai#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
While working on pydantic/pydantic-ai#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
genaidid tooAdditional context
I have just added a small warning for now.
https://pydantic.dev/docs/ai/models/google/#streaming-cancellation