23 lines
580 B
Python
23 lines
580 B
Python
|
from argparse import ArgumentParser
|
||
|
from contextlib import closing
|
||
|
from time import sleep
|
||
|
|
||
|
import requests
|
||
|
|
||
|
|
||
|
def main():
|
||
|
parser = ArgumentParser(description="block until the given endpoints return 200")
|
||
|
parser.add_argument('endpoints', type=str, nargs='+', help='the endpoints to wait for')
|
||
|
for endpoint in parser.parse_args().endpoints:
|
||
|
listening = False
|
||
|
while not listening:
|
||
|
try:
|
||
|
listening = requests.get(endpoint).status_code == 200
|
||
|
except requests.exceptions.ConnectionError:
|
||
|
pass
|
||
|
sleep(1)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|