googleapis / googleapis/python-genai

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

未关闭
#2,425 1 条评论 0 个 reaction 已指派 1 人 已被 @Venkaiahbabuneelam 认领 在 GitHub 查看
priority: p3 type: feature request
主要语言
Python
星标
4k
派生
1k
平均合并
2 天 11 小时
30 天内合并 PR
40

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。