Subinterpreters running on the main thread should handle signals
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
Proposal:
It's currently impossible to interrupt long-running operations inside subinterpreters:
from concurrent import interpreters
interp = interpreters.create()
interp.exec("import time; time.sleep(100)") # Cannot CTRL^C!
This is because _Py_ThreadCanHandleSignals explicitly requires the main interpreter:
After thinking about this for a while, I can't see any real reason why stdlib interpreters shouldn't be able to handle signals (in the main thread). It's probably a slight compatibility break for legacy C API subinterpreters, so we can just disable it for them (and add the new option to handle signals behind an interpreter configuration setting).
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Quickly discussed in-person a few months ago with @ericsnowcurrently and @colesbury. I don't think we came to a consensus, but there wasn't any pushback as far as I could tell.
Linked PRs
- gh-137174
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Include/internal/pycore_pystate.h の _Py_ThreadCanHandleSignals と、issue 内の concurrent.interpreters の例を読んでください。先に進む前に、リンクされている PR gh-137174 を確認してください。これにより、指定されている legacy C API 互換性を維持しながら、Ctrl-C でメインスレッドのサブインタープリターにおける長時間実行される操作を中断できるようになります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- operating-systems
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100