MCPcopy Index your code
hub / github.com/ipython/ipython / kill_bg_processes

Method kill_bg_processes

IPython/core/magics/script.py:372–402  ·  view source on GitHub ↗

Kill all BG processes which are still running.

(self)

Source from the content-addressed store, hash-verified

370 print("All background processes were killed.")
371
372 def kill_bg_processes(self):
373 """Kill all BG processes which are still running."""
374 if not self.bg_processes:
375 return
376 for p in self.bg_processes:
377 if p.returncode is None:
378 try:
379 p.send_signal(signal.SIGINT)
380 except:
381 pass
382 time.sleep(0.1)
383 self._gc_bg_processes()
384 if not self.bg_processes:
385 return
386 for p in self.bg_processes:
387 if p.returncode is None:
388 try:
389 p.terminate()
390 except:
391 pass
392 time.sleep(0.1)
393 self._gc_bg_processes()
394 if not self.bg_processes:
395 return
396 for p in self.bg_processes:
397 if p.returncode is None:
398 try:
399 p.kill()
400 except:
401 pass
402 self._gc_bg_processes()
403
404 def _gc_bg_processes(self):
405 self.bg_processes = [p for p in self.bg_processes if p.returncode is None]

Callers 2

__del__Method · 0.95
killbgscriptsMethod · 0.95

Calls 1

_gc_bg_processesMethod · 0.95

Tested by

no test coverage detected