Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security file is not removed after shutdown by Ctrl+C or kill -INT #1601

Closed
tkf opened this issue Apr 15, 2012 · 7 comments · Fixed by #1609
Closed

Security file is not removed after shutdown by Ctrl+C or kill -INT #1601

tkf opened this issue Apr 15, 2012 · 7 comments · Fixed by #1609
Milestone

Comments

@tkf
Copy link
Contributor

tkf commented Apr 15, 2012

I am using IPython 0.12 (Ubuntu 11.10, Python 2.7.2+).
This is how to reproduce. I just open one new notebook after starting the server.

% ipython profile create test
[ProfileCreate] Generating default config file: u'/home/takafumi/.config/ipython/p
rofile_test/ipython_config.py'
[ProfileCreate] Generating default config file: u'/home/takafumi/.config/ipython/p
rofile_test/ipython_qtconsole_config.py'
[ProfileCreate] Generating default config file: u'/home/takafumi/.config/ipython/p
rofile_test/ipython_notebook_config.py'
% ipython notebook --profile=test
[NotebookApp] Using existing profile dir: u'/home/takafumi/.config/ipython/profile_test'
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888
[NotebookApp] Use Control-C to stop this server and shut down all kernels.
Created new window in existing browser session.
[NotebookApp] Using MathJax from CDN
[NotebookApp] Kernel started: 5946f2c5-4a2f-434f-8962-ef379d7969a0
[NotebookApp] Connecting to: tcp://127.0.0.1:42572
[NotebookApp] Connecting to: tcp://127.0.0.1:39724
[NotebookApp] Connecting to: tcp://127.0.0.1:54142
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-5946f2c5-4a2f-434f-8962-ef379d7969a0.json --profile test
^C
% ls ~/.config/ipython/profile_test/security/
kernel-5946f2c5-4a2f-434f-8962-ef379d7969a0.json

BTW, is it safe to do rm ~/.config/ipython/profile_*/security/* when there is no IPython instance running?

@tkf
Copy link
Contributor Author

tkf commented Apr 15, 2012

OK, I found that KeyboardInterrupt is treated in the master branch. But it does not treat shutdown by kill, right?

@minrk
Copy link
Member

minrk commented Apr 15, 2012

OK, I found that KeyboardInterrupt is treated in the master branch. But it does not treat shutdown by kill, right?

Yes, master does a much better job cleaning up after itself, but that does not include kill (that's kind of the point of Kill - you can't handle it).

is it safe to do rm ~/.config/ipython/profile_*/security/* when there is no IPython instance running?

Yes, this is always safe. In fact, I've been meaning to add a simple command ipython profile clean, which would remove everything in the log/security/pid directories, because they can grow.

@tkf
Copy link
Contributor Author

tkf commented Apr 15, 2012

Cleaning command sounds nice!

You can handle kill by doing something with the signal module: http://danielkaes.wordpress.com/2009/06/04/how-to-catch-kill-events-with-python/
I suggest to handle SIGTERM.

@minrk
Copy link
Member

minrk commented Apr 15, 2012

TERM is not KILL - you cannot catch KILL, but we might as well catch TERM as well as INT.

@tkf
Copy link
Contributor Author

tkf commented Apr 15, 2012

Sorry, I mean kill command (without option, resulting in TERM). Yes, it would be much better if IPython can handle it.

@minrk
Copy link
Member

minrk commented Apr 15, 2012

See PR #1609

@tkf
Copy link
Contributor Author

tkf commented Apr 15, 2012

Great! I will close the issue.

@tkf tkf closed this as completed Apr 15, 2012
fperez added a commit to fperez/ipython that referenced this issue Apr 17, 2012
exit notebook cleanly on SIGINT, SIGTERM, and add a safety (text) dialog to ask for exit confirmation.  This prevents an accidental Ctrl-C in the wrong window from destroying a user's potentially large set of notebooks that could have taken a long time to create.

Closes ipython#1601
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
exit notebook cleanly on SIGINT, SIGTERM, and add a safety (text) dialog to ask for exit confirmation.  This prevents an accidental Ctrl-C in the wrong window from destroying a user's potentially large set of notebooks that could have taken a long time to create.

Closes ipython#1601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants