Skip to content

Commit 8781de9

Browse files
committed
runtime_adapter.py: on timeout, use SIGTERM to stop the child
XXX what to do for non-unix platforms?
1 parent 6dbcca3 commit 8781de9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test-runner/wasi_test_runner/runtime_adapter.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@ def run_test(
4242
+ [e for env in self._env_to_list(env_variables) for e in ("--env", env)]
4343
)
4444

45-
result = subprocess.run(
45+
p = subprocess.Popen(
4646
args,
47-
capture_output=True,
47+
stdout=subprocess.PIPE,
48+
stderr=subprocess.PIPE,
4849
text=True,
49-
check=False,
5050
cwd=Path(test_path).parent,
51-
timeout=3.
5251
)
53-
return Output(result.returncode, result.stdout, result.stderr)
52+
try:
53+
out, err = p.communicate(timeout=3)
54+
except subprocess.TimeoutExpired:
55+
p.terminate()
56+
p.wait()
57+
raise
58+
return Output(p.returncode, out, err)
5459

5560
@staticmethod
5661
def _abs(path: str) -> str:

0 commit comments

Comments
 (0)