diff --git a/IPython/core/magics/script.py b/IPython/core/magics/script.py index be8fa94..3fbddc3 100644 --- a/IPython/core/magics/script.py +++ b/IPython/core/magics/script.py @@ -246,6 +246,8 @@ class ScriptMagics(Magics): def kill_bg_processes(self): """Kill all BG processes which are still running.""" + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -253,6 +255,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -260,6 +265,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: