diff --git a/python/grpcdemo_client.py b/python/grpcdemo_client.py index ff7ed20..4d2c0c3 100644 --- a/python/grpcdemo_client.py +++ b/python/grpcdemo_client.py @@ -6,14 +6,23 @@ import sys -PORTNO = 6000 +PORTNO = 6000 +TIMEOUT = 30 def run(): channel = grpc.insecure_channel('localhost:%s' % PORTNO) stub = grpcdemo_pb2_grpc.HostCommandStub(channel) - response = stub.runcommand(grpcdemo_pb2.Command(command=sys.argv[1])) - print(response.results) + 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() diff --git a/python/grpcdemo_server.py b/python/grpcdemo_server.py index 0d5bf8e..8335840 100644 --- a/python/grpcdemo_server.py +++ b/python/grpcdemo_server.py @@ -9,12 +9,14 @@ import subprocess +DELAY = 5 ONE_DAY = 60 * 60 * 24 # Sleep time in seconds PORTNO = 6000 class HostCommand(grpcdemo_pb2_grpc.HostCommandServicer): def runcommand(self, request, context): + time.sleep(DELAY) return grpcdemo_pb2.Results(results=subprocess.check_output(request.command.split()))