Files
swift-mirror/test/Inputs/timeout.py
Erik Eckstein f83bd2885d tests: fix the timeout.py script and move it to a more central place
A string->float conversion for the command line argument was missing
2020-04-10 20:10:24 +02:00

20 lines
380 B
Python

#!/uar/bin/env python
import subprocess
import sys
import threading
def watchdog(command, timeout=None):
process = subprocess.Popen(command)
timer = threading.Timer(timeout, process.kill)
try:
timer.start()
process.communicate()
finally:
timer.cancel()
if __name__ == '__main__':
watchdog(sys.argv[2:], timeout=float(sys.argv[1]))