option to not override signal handler
まだ誰も着手していません。
評価
調査の方向性
ipykernel/kernelbase.py の pre_handler_hook から開始し、dispatch_shell がそれをどのように呼び出すかを追跡してください。埋め込みアプリケーションが自身の SIGINT ハンドラーの置き換えをオプトアウトする方法を確認し、その後、カスタムハンドラーが維持されたまま、通常のカーネルのシグナル処理も引き続き機能することを検証してください。
索引モデルが issue の本文から書いたものです。
説明
See also https://github.com/jupyter/qtconsole/issues/490
Hey there,
how can I embed qtconsole into an application without it overriding my own application's custom sigint handler?
Assume you have code that does
std::signal(SIGINT, &handleSigInt);
...
// do not initialize signal handlers
const auto initsigs = 0;
Py_InitializeEx(initsigs);
Then it is embedding qtconsole eventually, but at that point the sigint handler will be unset:
Thread 1 "QiTissue" hit Breakpoint 3, __interceptor_sigaction (signum=2, act=0x7fffffff8a60, oldact=0x7fffffff8b00)
at /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc:55
55 in /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc
(gdb) bt
#0 __interceptor_sigaction(int, __sanitizer::__sanitizer_sigaction const*, __sanitizer::__sanitizer_sigaction*)
(signum=2, act=0x7fffffff8a60, oldact=0x7fffffff8b00)
at /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc:55
#1 0x00007fff5c055f0f in PyOS_setsig (sig=sig@entry=2, handler=handler@entry=0x7fff5c0b6fec <signal_handler>)
at Python/pylifecycle.c:2536
#2 0x00007fff5c0b849f in signal_signal_impl
(module=<optimized out>, handler=<built-in method default_int_handler of module object at remote 0x7fff51eeaa40>, signalnum=2) at ./Modules/signalmodule.c:505
#3 signal_signal (module=<optimized out>, args=<optimized out>, nargs=<optimized out>)
at ./Modules/clinic/signalmodule.c.h:141
#4 0x00007fff5bf7bbf8 in cfunction_vectorcall_FASTCALL
(func=<built-in method signal of module object at remote 0x7fff51eeaa40>, args=0x7fff58a24a88, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:426
or in python terms:
(gdb) py-bt
Traceback (most recent call first):
<built-in method signal of module object at remote 0x7fff51eeaa40>
File "/usr/lib/python3.9/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
File "/home/milian/.local/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 280, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "/home/milian/.local/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 257, in dispatch_shell
self.pre_handler_hook()
the kernelbase.py code seems to reset the signal handler unconditionally to some default which is highly unexpected to me:
def pre_handler_hook(self):
"""Hook to execute before calling message handler"""
# ensure default_int_handler during handler call
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
Is there a way to prevent this from happening?
- 主要言語
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main オープンarea: ci bug perceived difficulty: 3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-connect#1057 ·