From c3356dcacd40f9d597494cf12dc95603764ec932 Mon Sep 17 00:00:00 2001 From: barrierye Date: Mon, 6 Jul 2020 17:38:32 +0800 Subject: [PATCH] add concurrency_idx into init_op func --- python/pipeline/operator.py | 10 +++++----- python/pipeline/profiler.py | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/pipeline/operator.py b/python/pipeline/operator.py index 9a569abd..accfdfce 100644 --- a/python/pipeline/operator.py +++ b/python/pipeline/operator.py @@ -197,7 +197,7 @@ class Op(object): threads.append(t) return threads - def init_op(self): + def init_op(self, concurrency_idx): pass def _run_preprocess(self, parsed_data, data_id, log_func): @@ -343,10 +343,10 @@ class Op(object): if use_multithread: with self._for_init_op_lock: if not self._succ_init_op: - self.init_op() + self.init_op(concurrency_idx) self._succ_init_op = True else: - self.init_op() + self.init_op(concurrency_idx) except Exception as e: _LOGGER.error(log(e)) os._exit(-1) @@ -425,7 +425,7 @@ class RequestOp(Op): name="@G", input_ops=[], concurrency=concurrency) # init op try: - self.init_op() + self.init_op(0) except Exception as e: _LOGGER.error(e) os._exit(-1) @@ -450,7 +450,7 @@ class ResponseOp(Op): name="@R", input_ops=input_ops, concurrency=concurrency) # init op try: - self.init_op() + self.init_op(0) except Exception as e: _LOGGER.error(e) os._exit(-1) diff --git a/python/pipeline/profiler.py b/python/pipeline/profiler.py index df497c48..e6fe43b1 100644 --- a/python/pipeline/profiler.py +++ b/python/pipeline/profiler.py @@ -50,6 +50,8 @@ class TimeProfiler(object): self._time_record.put((name, tag, timestamp)) def print_profile(self): + if self._enable is False: + return sys.stderr.write(self.gen_profile_str()) def gen_profile_str(self): -- GitLab