MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / reap

Function reap

battlecode-manager/player_plain.py:98–122  ·  view source on GitHub ↗

Tries hard to terminate and ultimately kill all the children of this process.

(process, timeout=3)

Source from the content-addressed store, hash-verified

96 super().destroy()
97
98def reap(process, timeout=3):
99 "Tries hard to terminate and ultimately kill all the children of this process."
100 def on_terminate(proc):
101 pass
102 # print("process {} terminated with exit code {}".format(proc.pid, proc.returncode))
103
104 try:
105 procs = process.children(recursive=True)
106 # send SIGTERM
107 for p in procs:
108 p.terminate()
109 gone, alive = psutil.wait_procs(procs, timeout=timeout, callback=on_terminate)
110 if alive:
111 # send SIGKILL
112 for p in alive:
113 p.kill()
114 gone, alive = psutil.wait_procs(alive, timeout=timeout, callback=on_terminate)
115 if alive:
116 # give up
117 for p in alive:
118 print("process {} survived SIGKILL; giving up" % p.pid)
119
120 process.kill()
121 except:
122 print("Killing failed; assuming process exited early.")
123
124def suspend(process):
125

Callers 1

destroyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected