Files
mtusi2026lab2/scripts/wait_ready.py
T

18 lines
578 B
Python

"""Дождаться HTTP readiness перед запуском проверок."""
import argparse
import time
import urllib.request
parser=argparse.ArgumentParser()
parser.add_argument('--base-url',default='http://localhost:8080')
args=parser.parse_args()
for _ in range(120):
try:
with urllib.request.urlopen(args.base_url+'/health/ready',timeout=2) as response:
if response.status==200:
print('PASS: API ready')
break
except Exception:
time.sleep(0.5)
else:
raise SystemExit('API readiness timeout')