We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b6a0162 + 1b8c109 commit 694c202Copy full SHA for 694c202
test/Inputs/timeout.py
@@ -2,17 +2,17 @@
2
3
import subprocess
4
import sys
5
-import threading
6
7
8
def watchdog(command, timeout=None):
9
process = subprocess.Popen(command)
10
- timer = threading.Timer(timeout, process.kill)
11
try:
12
- timer.start()
13
- process.communicate()
14
- finally:
15
- timer.cancel()
+ process.communicate(timeout=timeout)
+ except subprocess.TimeoutExpired:
+ process.kill()
+ sys.exit(
+ 'error: command timed out after {} seconds: {}'
+ .format(timeout, ' '.join(sys.argv[2:])))
16
17
18
if __name__ == '__main__':
0 commit comments