You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The response-streaming calls are inherently asynchronous in Python, so the routeguide example should demonstrate the overall mechanics of it.
To make a response-unary call asynchronous, instead of making the call like: response = stub.SayHello(...), you can call the future method of the callable:
from __future__ importprint_functionimportgrpcimporttimeimporthelloworld_pb2importhelloworld_pb2_grpcdefrun():
defprocess_response(call_future):
print(call_future.result())
channel=grpc.insecure_channel('localhost:50051')
stub=helloworld_pb2_grpc.GreeterStub(channel)
call_future=stub.SayHello.future(helloworld_pb2.HelloRequest(name='you'))
call_future.add_done_callback(process_response)
if__name__=='__main__':
run()
# do not shutdown the main thread to give a chance for async callbacks to # receive their reponses.whileTrue:
time.sleep(100000)
I want to create an async client with python, how could I do it, I can not find any example about it
The text was updated successfully, but these errors were encountered: