From 012d228ad5455b7a226c2f524ae04e95bb8ed1a8 2012-06-13 14:17:22 From: Takafumi Arakaki Date: 2012-06-13 14:17:22 Subject: [PATCH] Add --proc option to %%script This change allows, for example, user to terminate the process started by %%script cell magic. --- diff --git a/IPython/core/magics/script.py b/IPython/core/magics/script.py index 0158be9..8099530 100644 --- a/IPython/core/magics/script.py +++ b/IPython/core/magics/script.py @@ -58,6 +58,12 @@ def script_args(f): with --out/err. """ ), + magic_arguments.argument( + '--proc', type=str, + help="""The variable in which to store Popen instance. + This is used only when --bg option is given. + """ + ), ] for arg in args: f = arg(f) @@ -193,6 +199,8 @@ class ScriptMagics(Magics, Configurable): if args.err: self.shell.user_ns[args.err] = p.stderr self.job_manager.new(self._run_script, p, cell) + if args.proc: + self.shell.user_ns[args.proc] = p return out, err = p.communicate(cell)