`select.BaseSelector.select` do not conform to documentation with regard to signal handling
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
According to documentation in https://docs.python.org/3/library/selectors.html#selectors.BaseSelector.select:
.. versionchanged:: 3.5
The selector is now retried with a recomputed timeout when interrupted
by a signal if the signal handler did not raise an exception (see
:pep:`475` for the rationale), instead of returning an empty list
of events before the timeout.
However, as of writing this issue, selectors.SelectSelector.select and co can't differentiate between InterruptedError and timeout, as this exceptions is caught in in those methods.
While select.select shouldn't raise InterruptedError, such exception could be raised in a signal handler, therefore causing selectors.SelectSelector.select to return an empty list (instead of the raised exception), as-if it was a timeout.
The behaviour that I would expect has been implemented in https://github.com/python/cpython/commit/f70e1ca0fc30426d12aa8fc6684764ee11a66777, however it has been reverted in a following commit https://github.com/python/cpython/commit/90ecfe65e68#diff-671465c62a2c7c951b397550dc8f2f1c03860af4c089299e6edea29347cf6018 . It is unclear to me if it is an oversight, or if this revert was expected.
I only tested this for selectors.SelectSelector, but looking at the sources, I would expect the same behaviour exist for all select.*Selector classes
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-120002
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 selectors.SelectSelector.select 开始,将其对信号中断的处理方式与文档中描述的 BaseSelector.select 行为进行比较。检查链接的 PR gh-120002 和所引用的提交,以了解预期的解决方案,然后确认 select.*Selector 类是否需要一致的处理方式和回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100