Newer
Older
grpcdemo / python / grpcdemo_client.py
from __future__ import print_function

import grpc
import grpcdemo_pb2
import grpcdemo_pb2_grpc

import sys
import time

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]), CALL_TIMEOUT)

  response.add_done_callback(MyCallback)
  time.sleep(WAIT_TIME)

def MyCallback(foo):
  print(foo.result())

if __name__ == '__main__':
  run()