diff --git a/python/grpcdemo_client.py b/python/grpcdemo_client.py index 95a9158..0a476a2 100644 --- a/python/grpcdemo_client.py +++ b/python/grpcdemo_client.py @@ -7,24 +7,20 @@ import sys import time -PORTNO = 6000 -TIMEOUT = 30 +PORTNO = 6000 +CALL_TIMEOUT = 30 +WAIT_TIME = 10 def run(): channel = grpc.insecure_channel('localhost:%s' % PORTNO) stub = grpcdemo_pb2_grpc.HostCommandStub(channel) - response = stub.runcommand.future(grpcdemo_pb2.Command(command=sys.argv[1]), TIMEOUT) + response = stub.runcommand.future(grpcdemo_pb2.Command(command=sys.argv[1]), CALL_TIMEOUT) - while not response.done(): - print("Waiting ...") - time.sleep(2) - - print(response.result()) - - + response.add_done_callback(MyCallback) + time.sleep(WAIT_TIME) def MyCallback(foo): - print(foo) + print(foo.result()) if __name__ == '__main__': run()