def terminate(self):
if not self.is_running():
print (" ...%s processes already dead" % self.name)
return
tps = []
for process in self.processes:
if process:
parent_pid = process.pid
parent = psutil.Process(parent_pid)
try:
for child in parent.children(recursive=True):
child.kill()
parent.kill()
except Exception as e:
print (" !! %s: %s" % (self.name, e))
else:
tps.append(process.pid)
print (" [x] Terminated: %s - pId(s): %s" % (self.name, ', '.join(str(p) for p in tps)))
self.commands = []
self.output_filenames = []
self.processes = []
self.pid_commands.clear()
评论列表
文章目录