Ejemplo n.º 1
0
def run():
    counter = 0
    pid = os.getgid()
    with grpc.insecure_channel("localhost:7860") as channel:
        stub = pingpong_pb2_grpc.PingPongServiceStub(channel)

        while True:
            try:
                start = time.time()

                try:
                    response = stub.ping(pingpong_pb2.Ping(count=counter))
                except grpc.RpcError:
                    response = stub.ping(pingpong_pb2.Ping(count=counter))

                
                counter = response.count
                if counter % 5000 == 0:
                    print( "%4f : response=%s : procid=%i" % (time.time()-start, response.count, pid))
            except KeyboardInterrupt:
                print("KeyboardInterrupt")
                channel.unsubscribe(close)
                exit()
Ejemplo n.º 2
0
def run():
    counter = 0
    pid = os.getpid()
    with grpc.insecure_channel("localhost:9999") as channel:
        stub = pingpong_pb2_grpc.PingPongServiceStub(channel)
        while True:
            try:
                start = time.time()
                response = stub.ping(pingpong_pb2.Ping(count=counter))
                counter = response.count
                if counter % 1000 == 0:
                    print("%.4f : resp=%s : procid=%i" %
                          (time.time() - start, response.count, pid))
                    # counter = 0
                time.sleep(0.001)
            except KeyboardInterrupt:
                channel.unsubscribe(close)
                exit()
Ejemplo n.º 3
0
def run(port=9999):
    "The run method, that sends gRPC conformant messsages to the server"
    counter = 0
    pid = os.getpid()
    with grpc.insecure_channel("localhost:{}".format(port)) as channel:
        stub = pingpong_pb2_grpc.PingPongServiceStub(channel)
        while True:
            try:
                start = time.time()
                response = stub.ping(pingpong_pb2.Ping(count=counter))
                counter = response.count
                if counter % 1000 == 0:
                    print("%.4f : resp=%s : procid=%i" %
                          (time.time() - start, response.count, pid))
                    # counter = 0
                time.sleep(0.001)
            except KeyboardInterrupt:
                print("KeyboardInterrupt")
                channel.unsubscribe(close)
                exit()