Files
swift-mirror/test/Inputs/timeout.py
Daniel Duan 3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00

20 lines
381 B
Python

#!/uar/bin/env python3
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]))