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 for server connect...')
time.sleep(1)
Strangely, though this works, it takes quite a while to connect when the server is started after the client (about 10 seconds or more) before showing the result. A quick internet search shows there is a WaitForReady option in C#, but there doesn't seem to be an equivalent in Python? How else can I check if a connection is ready?
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a2f41bce-007a-4adb-8032-1ea3af6c5100%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There are a few ways to track channel state in Python. If you only want to block until it is connected, trygrpc.channel_ready_future(channel).result()
On Fri, Aug 18, 2017 at 7:23 AM, Julian Gold <julian.b...@gmail.com> wrote:
I am working on an architecture with a single client and multiple servers. GRPC raises an exception if the client starts without a server present, so I tried modifying the HelloWorld sample to wait until a call succeeds: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 for server connect...')
time.sleep(1)
Strangely, though this works, it takes quite a while to connect when the server is started after the client (about 10 seconds or more) before showing the result. A quick internet search shows there is a WaitForReady option in C#, but there doesn't seem to be an equivalent in Python? How else can I check if a connection is ready?
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.