python / python/cpython

Allow Interpreter.prepare_main() Even If the Interpreter Is Running?

オープン
#139,523 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.14 3.15 stdlib topic-subinterpreters type-feature
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

Feature or enhancement

Proposal:

Currently Interpreter.prepare_main() (from concurrent.interpreters) fails if the interpreter is running. (See Interpreter.is_running(). It may make sense to relax this restriction.

For example, it might make sense for a subinterpreter to call prepare_main() on the main interpreter to share a cross-interpreter Queue. Currently that fails because the main interpreter is always considered to be "running".
The answer for now is "make sure the main interpreter creates any queues it needs to share" and that might be good enough.

It's something I hadn't considered before and I'm not exactly sure yet that allowing it would be the right thing. The problem is that it isn't intuitively obvious to users (or me) how externally modifying an interpreter's __main__ module may affect code running there in a different thread.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず concurrent.interpreters.Interpreter.prepare_main() と Interpreter.is_running() を確認し、実行中のインタープリターに対する準備が拒否される理由に焦点を当てます。main への外部からの変更をスレッド間およびサブインタープリター間で許可しても安全かどうかを判断し、そのうえで制限を変更する前に必要な動作とテストを定義します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。