You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/test_utils/scripts/timeout.py

23 lines
469 B
Python

#!/usr/bin/env python
from __future__ import annotations
import argparse
import subprocess
import sys
parser = argparse.ArgumentParser()
parser.add_argument('duration', type=int)
parser.add_argument('command', nargs='+')
args = parser.parse_args()
try:
p = subprocess.run(
' '.join(args.command),
shell=True,
timeout=args.duration,
check=False,
)
sys.exit(p.returncode)
except subprocess.TimeoutExpired:
sys.exit(124)