Move wait_for_service into client; it'll be used from other things.

This commit is contained in:
Ian Gulliver
2016-04-02 10:56:14 -07:00
parent 1dc9b20aa1
commit e2c5f788bf
2 changed files with 1 additions and 1 deletions

View File

@@ -1,36 +0,0 @@
#!/usr/bin/python3
import argparse
import socket
import time
parser = argparse.ArgumentParser(description='iconograph wait_for_service')
parser.add_argument(
'--host',
dest='host',
action='store',
required=True)
parser.add_argument(
'--service',
dest='service',
action='store',
required=True)
FLAGS = parser.parse_args()
def main():
conn = (FLAGS.host, FLAGS.service)
print('Trying to connect to %s:%s' % conn)
while True:
try:
socket.create_connection(conn, timeout=5)
break
except Exception:
time.sleep(1)
continue
print('Connection successful')
if __name__ == '__main__':
main()