MCPcopy
hub / github.com/huangruiteng/CS-Notes / kill_proc

Function kill_proc

Notes/snippets/python-call-process-with-timeout.py:16–22  ·  view source on GitHub ↗
(p, p_name)

Source from the content-addressed store, hash-verified

14 stderr=subprocess.STDOUT)
15
16 def kill_proc(p, p_name):
17 nonlocal timed_out
18 if p.poll() is None:
19 p.terminate()
20 timed_out = True
21 logging.error(
22 "Process {} terminated due to timeout".format(p_name))
23
24 p_name = subprocess.list2cmdline(cmd_list)
25 timer = threading.Timer(timeout_secs, kill_proc, [proc, p_name])

Callers

nothing calls this directly

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected