`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