from __future__ import print_function import grpc import grpcdemo_pb2 import grpcdemo_pb2_grpc import sys PORTNO = 6000 TIMEOUT = 30 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) while not response.done: time.sleep(2) print(response.result()) def MyCallback(foo): print(foo) if __name__ == '__main__': run()