コード例 #1
0
ファイル: grpc_client.py プロジェクト: zouxiaoshi/QDServing
 def process_response(call_future):
     try:
         list_result = str_2_list_by_json(call_future.result().data)
         results.extend(list_result)
         tags.append(1)
         logging.info("--------------end_call_grpc-------------")
     except:
         logging.error("--------------fail_call_grpc-------------")
コード例 #2
0
ファイル: grpc_run.py プロジェクト: zouxiaoshi/QDServing
    def SendData(self, request, context):
        logging.info("start_get_data, url: {}".format( request.name) )
        start = time.time()
        code, audios_data = inference(request.name)
        end = time.time()

        if code == 0:
            logging.info("success_get_data, time: {}s, data_size: {}, url: {}".format( (end - start), len(audios_data), request.name) )
        else:
            logging.error("fail_get_data, time: {}s, data_size: {}, url: {}".format( (end - start), len(audios_data), request.name) )

        return call_ant_pb2.AntReply(code=code, data=audios_data)
コード例 #3
0
    def SendData(self, request, context):
        # logging.info("start_get_data, url: {}".format(request.name) )
        start = time.time()
        code, data = infer(request.image)
        end = time.time()

        if code == 200:
            logging.info(
                "success_get_data, time: {}s, size: {}, url: {}".format(
                    (end - start), len(data), 'test'))
        else:
            logging.error("fail_get_data, time: {}s, size: {}, url: {}".format(
                (end - start), len(data), 'test'))

        return PiReply(code=code, data=data)
コード例 #4
0
ファイル: grpc_client.py プロジェクト: zouxiaoshi/QDServing
def get_res_by_grpc(grpc_host, text):

    logging.info("start_call_grpc, grpc_host: {}, url: {}".format( grpc_host, text ) )

    start = time.time()
    channel = grpc.insecure_channel(grpc_host)
    stub = call_ant_pb2_grpc.GreeterStub(channel)
    response = stub.SendData(call_ant_pb2.AntRequest(name=text))
    end = time.time()

    if response.code == 200:
        logging.info("success_data_by_grpc, time: {}s, size: {}, url: {}".format( (end-start), len(response.data), text) )
    else:
        logging.error("fail_call_grpc, time: {}s, data_size: {}, url: {}".format( (end-start), len(response.data), text) )

    return response.data
コード例 #5
0
ファイル: grpc_client.py プロジェクト: zouxiaoshi/QDServing
def get_sort_by_grpc(grpc_host, resp_data, list_url):

    logging.info("start_call_grpc, grpc_host: {}, url: {}".format( grpc_host, list_url ) )
    start = time.time()
    channel = grpc.insecure_channel(grpc_host)
    stub = call_ant_pb2_grpc.GreeterStub(channel)
    response = stub.SendData(call_ant_pb2.AntRequest(name=resp_data))
    end = time.time()
    list_result = str_2_list_by_json(response.data)

    if response.code == 200:
        logging.info("success_call_grpc, time: {}s, data_size: {}, url: {}".format( (end-start), len(response.data), list_url) )
    else:
        logging.error("fail_call_grpc, time: {}s, data_size: {}, url: {}".format( (end-start), len(response.data), list_url) )

    return list_result
コード例 #6
0
ファイル: grpc_client.py プロジェクト: mukangt/FRServing
def get_res_by_grpc(grpc_host, img_64):
    logging.info("start_call_grpc, grpc_host: {}, url: {}".format(
        grpc_host, 'test'))

    start = time.time()
    channel = grpc.insecure_channel(grpc_host)
    stub = PiServiceStub(channel)
    response = stub.SendData(PiRequest(image=img_64))
    end = time.time()

    if response.code == 200:
        logging.info("success_call_grpc, time: {}s, size: {}, url: {}".format(
            (end - start), len(response.data), 'text'))
    else:
        logging.error("fail_call_grpc, time: {}s, size: {}, url: {}".format(
            (end - start), len(response.data), 'text'))

    return response.code, response.data
コード例 #7
0
ファイル: grpc_client.py プロジェクト: zouxiaoshi/QDServing
def get_sort_by_grpc_async(grpc_host, resp_data, list_url, results = [], tags=[]):

    def process_response(call_future):
        try:
            list_result = str_2_list_by_json(call_future.result().data)
            results.extend(list_result)
            tags.append(1)
            logging.info("--------------end_call_grpc-------------")
        except:
            logging.error("--------------fail_call_grpc-------------")

    ret = True
    try:
        logging.info("start_call_grpc, grpc_host: {}s, url: {}".format( grpc_host, list_url) )
        channel = grpc.insecure_channel(grpc_host)
        stub = call_ant_pb2_grpc.GreeterStub(channel)
        call_future = stub.SendData.future(call_ant_pb2.AntRequest(name=resp_data))
        call_future.add_done_callback(process_response)
    except:
        tags.append(1)
        logging.error("-----fail_get_sort_by_grpc, host: {}".format( grpc_host ) )
        ret = False

    return ret