Closed
【Bug】writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass) #131
wangdefeng1Add on 14 days agoClosed at 7 days ago
14 days ago Added label: sig/sig-agent-gateway
openJiuwen-bot
14 days ago Comments:
14 days ago Comments:
欢迎来到 openJiuwen 社区
Hey @wangdefeng1 , 感谢你对社区的贡献.
机器人使用手册
有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。
联系指引
有疑问可以联系 SIG: sig-agent-gateway ,
维护者是: @YiyangShao, @mingo007 ,
审核者是: @d-0771, @gcw_hx9prznZ, @yechenzhen, @yukuanj .


14 days ago Modify description of issue
14 days ago Associated pull request
14 days ago Modify description of issue
14 days ago changed 关联分支 from [] to [develop]
14 days ago changed custom category from Experience-Feedback to Bug-Report
14 days ago Change title to "【Bug】writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass)", originally titled "writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass)".
14 days ago Change title to "【Bug】writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass)", originally titled "writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass)".
7 days ago Close issue
7 days ago changed custom state from TODO to DONE
2 days ago Associated pull request
Paired: GitHub #190 ↔ GitCode #131
位置:
agent_gateway/routing/base_ws_channel.py:512-515、542-545(a0e260b)问题
writer.cancel() try: await writer except (asyncio.CancelledError, Exception): passawait一个已被取消的 task 会向等待方抛CancelledError,因此这里吞掉的既有“子任务被取消”(正确),也有“本协程被取消”(错误)。影响
断连收尾或关停过程中,若上层用
asyncio.wait_for(stop(), timeout=...)超时、或服务优雅退出触发取消,取消被静默吞掉,收尾继续往下跑并正常返回,取消不再向上传播。修复
writer.cancel() await asyncio.gather(writer, return_exceptions=True)子任务的取消作为返回值收集,本协程真被取消时 gather 照常抛出。
回归用例
tests/unit_tests/routing/test_base_ws_channel_cancellation.py(3 例),修复前第二例Failed: DID NOT RAISE CancelledError。关联修复 MR:!138(分支
fix/gateway-cancel-propagation,位于 forkwangdefeng1/agent-gateway)