mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Replace timeout.sh with timeout.py. This makes it portable to other platforms like Windows.
20 lines
373 B
Python
20 lines
373 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=sys.argv[1])
|