[IPython-User] Setting a timeout for "!" (shell) commands

Paul Moore p.f.moore@gmail....
Mon Jun 3 08:29:41 CDT 2013


I use IPython with Python 3 on Windows. A common mistake that I make is to
run a shell command in the notebook (or GUI) which is interactive. It's one
of those "accidental muscle memory" habits I can't break :-( As the command
is run in a hidden window, the interactive prompt is unavailable and the
IPython kernel freezes.

While this is obviously a (particularly dumb :-)) user error, it's very
hard to recover from. I have to run Process Explorer, hunt for the
appropriate shell subprocess, and kill it. That's not always easy, and
never convenient. I have tried the "Kernel/Interrupt Kernel" menu item, and
it does not kill the subprocess (I don't know if that's by design or a bug).

Would it be possible (or is there already a way) to kill such rogue
subprocesses? The obvious approach would be an extra menu item like
"Kernel/Interrupt" (or even fix that to kill subprocesses if the current
behaviour is deemed a bug).

Other options that I thought of while looking into this, that might help:

1. A list of shell commands to "blacklist", because they are known to be
interactive (less, vim, for example). There would be grey areas, though
(python is interactive unless a script name is given) that might make this
less useful in practice.

2. A user-configurable timeout for shell commands. Obviously this would
have to be off by default as it would break big data-processing commands
badly, but it could be settable interactively.

More generally, is the "run a shell command" behaviour of ipython
accessible to user code? If it were, then I could maybe experiment with
adding my own hooks to try out some of these ideas. (Actually, making the
shell command running code subclassable or otherwise configurable might be
interesting as a general enhancement - just a thought...)

Thanks,
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130603/793b65d3/attachment.html 


More information about the IPython-User mailing list