MCPcopy Create free account
hub / github.com/ipython/ipython / cleanup_process

Method cleanup_process

IPython/testing/iptestcontroller.py:80–102  ·  view source on GitHub ↗

Cleanup on exit by killing any leftover processes.

(self)

Source from the content-addressed store, hash-verified

78 return self.process.returncode
79
80 def cleanup_process(self):
81 """Cleanup on exit by killing any leftover processes."""
82 subp = self.process
83 if subp is None or (subp.poll() is not None):
84 return # Process doesn't exist, or is already dead.
85
86 try:
87 print('Cleaning up stale PID: %d' % subp.pid)
88 subp.kill()
89 except: # (OSError, WindowsError) ?
90 # This is just a best effort, if we fail or the process was
91 # really gone, ignore it.
92 pass
93 else:
94 for i in range(10):
95 if subp.poll() is None:
96 time.sleep(0.1)
97 else:
98 break
99
100 if subp.poll() is None:
101 # The process did not die...
102 print('... failed. Manual cleanup may be required.')
103
104 def cleanup(self):
105 "Kill process if it's still alive, and clean up temporary directories"

Callers 1

cleanupMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected