IncludeOS icon indicating copy to clipboard operation
IncludeOS copied to clipboard

test.py's using subprocess directly needs their own timeouts

Open alfreb opened this issue 7 years ago • 0 comments

vmrunner has a timeout thread that will kill qemu and all child processes after a given time. This doesn't kill subprocesses started directly by test.py, such as stress/test.py and many others. The stress test is e.g. calling subprocess.check_call(["httperf","--hog", ...) etc. which apparently can hang forever.

One solution is to make the vmrunner timeout kill everything including itself, but that seems a little wrong wrt. what the vmrunner is supposed to do (run a vm, possibly for a finite time). Another solution is to require each test.py to be in charge of their own subprocesses. The subprocess module in Python 3 has a timeout parameter, which is also backported to python 2.7. $ pip install subprocess32 And then in test.py:

import subprocess32
...
supprocess32.check_call(..., timeout=5)

works for me, e.g. a call to supprocess32.check_call(["yes"], timeout=10) will result in an exception and TimeoutExpired: Command '['yes']' timed out after 10 seconds before control is handed back to test.py for graceful exit.

alfreb avatar Oct 04 '18 16:10 alfreb