Skip to content

Comments

Fix interrupting Spyder kernel#482

Merged
jitseniesen merged 4 commits intospyder-ide:masterfrom
jitseniesen:interrupt
Mar 29, 2025
Merged

Fix interrupting Spyder kernel#482
jitseniesen merged 4 commits intospyder-ide:masterfrom
jitseniesen:interrupt

Conversation

@jitseniesen
Copy link
Member

Interrupting a kernel is done on Unix by sending SIGINT to the Python process. However, Spyder kernels use conda run to run the kernel in the correct environment. The SIGINT signal should not be sent to the conda run process, because that causes it to quit. Instead, find the Python process started by conda run, because it will handle SIGINT correctly by raising a KeyboardInterrupt.

This PR does some further clean up in the code for the notebook server because I now understand how to specify default configuration values instead of passing them on the command line.

Fixes #478

Specify sensible default values for Spyder in the Python code for
the notebook server, so that fewer arguments need to be specified
on the command line when starting the server.

The --password command line argument is removed because it does
not seem to do anything.
Interrupting a kernel is done on Unix by sending SIGINT to the
Python process. However, Spyder kernels use `conda run` to run the
kernel in the correct environment. The SIGINT signal should not be
sent to the `conda run` process, because that causes it to quit.
Instead, find the Python process started by `conda run`, because it
will handle SIGINT correctly by raising a KeyboardInterrupt.
@jitseniesen jitseniesen added this to the v0.6.2 milestone Mar 11, 2025
@jitseniesen jitseniesen self-assigned this Mar 11, 2025
The fix in the previous commit should only be applied if the
notebook kernel was started with `conda run`, in which case the
PID in the info file identifies the conda process. Otherwise,
the PID identifies the kernel process, as normal for Jupyter
kernel, and the normal implementation for interrupting should
be followed.
This does not really add a dependency because psutil is used in
Spyder so it is already an indirect dependency.
@jitseniesen jitseniesen merged commit 7ffce27 into spyder-ide:master Mar 29, 2025
18 checks passed
@jitseniesen jitseniesen deleted the interrupt branch March 29, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jupyter Notebook: "Interrupt kernel" restarts kernel, all variables lost

1 participant