Give PyErr_CheckSignals guide-level documentation
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Documentation
Compiled extensions that "want to be interruptible by user requests" need to call PyErr_CheckSignals periodically; when it returns -1, they should stop work, clean up after themselves, and return to the interpreter.
This function is not mentioned at all in the extending and embedding guide, and its reference documentation makes it sound unimportant. As a result, many extension authors are (it seems to me) not aware that it exists or that they ought to be calling it, and so many extensions that should be interruptible by user requests aren't. For example, if you execute this code
>>> import numpy as np
>>> rng = np.random.default_rng()
>>> x = rng.random(1000000000)
and then immediately hit control-C, you'll be waiting at least a few seconds before you get the prompt back.
PyErr_CheckSignals also has the unusual property of potentially executing arbitrary Python code before returning to its caller, which makes it easy to use unsafely. Making an extension interruptible throughout may necessitate calling PyErr_CheckSignals from innermost loops where one would ideally release the GIL, which makes that worse (see #133465).
Thus, I suggest that a guide to correct use of PyErr_CheckSignals should be added to the extending and embedding guide.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、PyErr_CheckSignalsのリファレンスドキュメントと併せて、拡張と埋め込みのガイドを読んでください。-1の戻り値の処理、クリーンアップ、任意のPythonコードを実行する可能性を含め、PyErr_CheckSignalsを安全に使用するためのガイドを追加してください。ドキュメントでは、拡張機能が割り込み可能な状態を維持する方法を明確にしてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 65/100