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

Aaron Meurer asmeurer@gmail....
Mon Jun 3 08:40:50 CDT 2013


On Jun 3, 2013, at 8:29 AM, Paul Moore <p.f.moore@gmail.com> wrote:

> 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.

Less and vim actually switch the tty somehow (I forget the exact
details). It might be possible to programmatically check for that.

Aaron Meurer

>
> 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.
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user


More information about the IPython-User mailing list