python - How to know if a GRPC server is available -
if grpc client starts before server, exits exception. application working on starts bunch of servers , clients (near) simultaneously, however, , have robust respect execution order. if client starts before server, want wait until server shows up.
i modified helloworld python client example follows:
done = false while not done: try: response = stub.sayhello(helloworld_pb2.hellorequest(name='you'), timeout=1) print("greeter client received: " + response.message) done = true except: print('waiting server connect...') time.sleep(1)
so if start client before server, 'waiting server connect...' message scrolling terminal window expected. start server, , connects... eventually. in fact takes ten seconds before 'hello you' messages appears, surprisingly long. why might slow, , there robust way check server connection?
take @ channelconnectivity - go programmer should same in python. create while/for loop , when "channelconnectivity" set "ready" create client connection , continue.
Comments
Post a Comment