`Kernel._control_lock` created after it may be used
まだ誰も着手していません。
評価
調査の方向性
問題は ipykernel/kernelbase.py の 347 行目付近にあり、_control_lock が初期化される前にアクセスされています。カーネルクラスの __init__ メソッドを確認して、_control_lock が設定される場所を確認してください。修正は、制御メッセージがディスパッチされる前にロックが作成されるようにすることです。パッチの参考としてリンクされたブランチを確認し、高遅延環境をシミュレートしてカーネルを実行して検証してください。
索引モデルが issue の本文から書いたものです。
説明
I ran into the following exception when running a Notebook inside VSCode with the python environment running on a remote machine (through the VSCode tunnel). The remote machine has a distributed file system which can cause significant latencies when starting a notebook from scratch, which can unearth race conditions that would be unlikely on a normal laptop or desktop machine. I guess our somewhat offbeat use case is the reason this did not get noticed before.
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 651, in get
value = obj._trait_values[self.name]
~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: '_control_lock'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/apps/gent/RHEL9/cascadelake-ib/software/PyZMQ/27.1.0-GCCcore-15.2.0/lib/python3.14/site-packages/zmq/eventloop/zmqstream.py", line 565, in _log_error
f.result()
~~~~~~~~^^
File "/apps/gent/RHEL9/cascadelake-ib/software/jupyter-server/2.19.0-GCCcore-15.2.0/lib/python3.14/site-packages/ipykernel/kernelbase.py", line 347, in dispatch_control
async with self._control_lock:
^^^^^^^^^^^^^^^^^^
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 706, in __get__
return self.get(obj, cls) # type:ignore[return-value]
~~~~~~~~^^^^^^^^^^
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 668, in get
value = self._validate(obj, default)
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 741, in _validate
value = self.validate(obj, value)
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 2319, in validate
self.error(obj, value)
~~~~~~~~~~^^^^^^^^^^^^
File "/apps/gent/RHEL9/cascadelake-ib/software/IPython/9.14.0-GCCcore-15.2.0/lib/python3.14/site-packages/traitlets/traitlets.py", line 850, in error
raise TraitError(e)
traitlets.traitlets.TraitError: The '_control_lock' trait of an IPythonKernel instance expected a Lock, not the NoneType None.
This was with ipykernel v7.2.0 on Redhat Linux 9 (remote machine, HPC infrastructure). I've written a patch for v7.2.0, so we can perform a minimal upgrade of our teaching setup:
https://github.com/tovrstra/ipykernel/tree/bugfix/control_lock_race
I think the same issue (_control_lock created too late) is still present in the main branch. I'll make a PR on the main branch in minute.
- 主要言語
- Python
- スター
- 734
- フォーク
- 411
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 9
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ipython/ipykernel のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
ipython/ipykernel の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
learningequality/ricecooker#747 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
run-llama/llama_index#23199 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
KhronosGroup/glTF-Blender-IO#2769 ·