ЛР 2 — БВТ2303 — Брезгунова — на 5
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import time
|
||||
from urllib.request import urlopen
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--base-url', default='http://localhost:8080')
|
||||
args = p.parse_args()
|
||||
deadline = time.monotonic()+90
|
||||
while True:
|
||||
try:
|
||||
with urlopen(args.base_url+'/health/ready', timeout=3) as response:
|
||||
if response.status == 200:
|
||||
print('API ready')
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
if time.monotonic() >= deadline:
|
||||
raise SystemExit('API did not become ready in 90 seconds')
|
||||
time.sleep(0.5)
|
||||
Reference in New Issue
Block a user