diff --git a/python/examples/fit_a_line/test_py_client.py b/python/examples/fit_a_line/test_py_client.py index 57ef3b405dfb94ebbdf398c7b2f28b617a51dab6..76fee2804daf6e98d0cb12a562e8b69ffa97742b 100644 --- a/python/examples/fit_a_line/test_py_client.py +++ b/python/examples/fit_a_line/test_py_client.py @@ -29,11 +29,11 @@ x = np.array( lp = LineProfiler() lp_wrapper = lp(client.predict) -for i in range(3): +for i in range(1): fetch_map = lp_wrapper( feed={"x": x}, fetch_with_type={"combine_op_output": "float"}) # fetch_map = client.predict( # feed={"x": x}, fetch_with_type={"combine_op_output": "float"}) print(fetch_map) -lp.print_stats() +#lp.print_stats() diff --git a/python/examples/fit_a_line/test_py_server.py b/python/examples/fit_a_line/test_py_server.py index 863ac55040f0b60aade4e2f6d103d7a7d34558ed..ff4542560a455af4b8256c8daf9b2c62ac5d8568 100644 --- a/python/examples/fit_a_line/test_py_server.py +++ b/python/examples/fit_a_line/test_py_server.py @@ -72,7 +72,9 @@ cnn_op = UciOp( client_config="uci_housing_client/serving_client_conf.prototxt", server_name="127.0.0.1:9393", fetch_names=["price"], - concurrency=1) + concurrency=1, + timeout=0.01, + retry=2) bow_op = UciOp( name="bow", @@ -86,7 +88,9 @@ bow_op = UciOp( client_config="uci_housing_client/serving_client_conf.prototxt", server_name="127.0.0.1:9393", fetch_names=["price"], - concurrency=1) + concurrency=1, + timeout=-1, + retry=1) combine_op = CombineOp( name="combine", @@ -94,12 +98,14 @@ combine_op = CombineOp( in_dtype='float', outputs=[out_channel], out_dtype='float', - concurrency=1) + concurrency=1, + timeout=-1, + retry=1) logging.info(read_channel.debug()) logging.info(combine_channel.debug()) logging.info(out_channel.debug()) -pyserver = PyServer(profile=False) +pyserver = PyServer(profile=False, retry=1) pyserver.add_channel(read_channel) pyserver.add_channel(combine_channel) pyserver.add_channel(out_channel) diff --git a/python/paddle_serving_server/pyserver.py b/python/paddle_serving_server/pyserver.py index c418710bb3f84bd1e4d8ae1b798de511b85cb360..420df4ef5079cd63ebc411fd157b1d5cf14b2a21 100644 --- a/python/paddle_serving_server/pyserver.py +++ b/python/paddle_serving_server/pyserver.py @@ -42,12 +42,16 @@ class _TimeProfiler(object): self._enable = enable def record(self, name_with_tag): + if self._enable is False: + return name_with_tag = name_with_tag.split("_") tag = name_with_tag[-1] name = '_'.join(name_with_tag[:-1]) self._time_record.put((name, tag, int(round(time.time() * 1000000)))) def print_profile(self): + if self._enable is False: + return sys.stderr.write(self._print_head) tmp = {} while not self._time_record.empty(): @@ -392,10 +396,12 @@ class Op(object): for i in range(self._retry): _profiler.record("{}{}-midp_0".format(self._name, concurrency_idx)) - if self._time > 0: + if self._timeout > 0: try: middata = func_timeout.func_timeout( - self._time, self.midprocess, args=(data, )) + self._timeout, + self.midprocess, + args=(data, )) except func_timeout.FunctionTimedOut: logging.error("error: timeout") error_info = "{}({}): timeout".format( @@ -520,6 +526,7 @@ class GeneralPythonService( data = python_service_channel_pb2.ChannelData() data_id = self._get_next_id() data.id = data_id + data.is_error = 0 for idx, name in enumerate(request.feed_var_names): logging.debug( self._log('name: {}'.format(request.feed_var_names[idx])))