提交 d0356b6d 编写于 作者: B barrierye

clean up code

上级 d8c1050a
此差异已折叠。
此差异已折叠。
...@@ -49,6 +49,9 @@ class _TimeProfiler(object): ...@@ -49,6 +49,9 @@ class _TimeProfiler(object):
self._enable = False self._enable = False
def enable(self, enable): def enable(self, enable):
if enable:
raise Exception(
"profile cannot be used in multiprocess version temporarily")
self._enable = enable self._enable = enable
def record(self, name_with_tag): def record(self, name_with_tag):
...@@ -368,17 +371,13 @@ class Channel(multiprocessing.queues.Queue): ...@@ -368,17 +371,13 @@ class Channel(multiprocessing.queues.Queue):
logging.debug( logging.debug(
self._log("{} try to get(with channel empty: {})". self._log("{} try to get(with channel empty: {})".
format(op_name, self.empty()))) format(op_name, self.empty())))
# For Python2, after putting an object on an empty queue there may # For queue multiprocess: after putting an object on
# be an infinitessimal delay before the queue's :meth:`~Queue.empty` # an empty queue there may be an infinitessimal delay
# before the queue's :meth:`~Queue.empty`
# see more: # see more:
# - https://bugs.python.org/issue18277 # - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21 # - https://hg.python.org/cpython/rev/860fc6a2bd21
if sys.version_info.major == 2:
resp = self.get(timeout=1e-3) resp = self.get(timeout=1e-3)
elif sys.version_info.major == 3:
resp = self.get(timeout=0)
else:
raise Exception("Error Python version")
break break
except Queue.Empty: except Queue.Empty:
logging.debug( logging.debug(
...@@ -409,17 +408,13 @@ class Channel(multiprocessing.queues.Queue): ...@@ -409,17 +408,13 @@ class Channel(multiprocessing.queues.Queue):
logging.debug( logging.debug(
self._log("{} try to get(with channel size: {})".format( self._log("{} try to get(with channel size: {})".format(
op_name, self.qsize()))) op_name, self.qsize())))
# For Python2, after putting an object on an empty queue there may # For queue multiprocess: after putting an object on
# be an infinitessimal delay before the queue's :meth:`~Queue.empty` # an empty queue there may be an infinitessimal delay
# before the queue's :meth:`~Queue.empty`
# see more: # see more:
# - https://bugs.python.org/issue18277 # - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21 # - https://hg.python.org/cpython/rev/860fc6a2bd21
if sys.version_info.major == 2:
channeldata = self.get(timeout=1e-3) channeldata = self.get(timeout=1e-3)
elif sys.version_info.major == 3:
channeldata = self.get(timeout=0)
else:
raise Exception("Error Python version")
self._front_res.append(channeldata) self._front_res.append(channeldata)
break break
except Queue.Empty: except Queue.Empty:
...@@ -584,7 +579,7 @@ class Op(object): ...@@ -584,7 +579,7 @@ class Op(object):
data_id, error_channeldata = None, None data_id, error_channeldata = None, None
if isinstance(channeldata, dict): if isinstance(channeldata, dict):
parsed_data = {} parsed_data = {}
key = channeldata.keys()[0] key = list(channeldata.keys())[0]
data_id = channeldata[key].id data_id = channeldata[key].id
for _, data in channeldata.items(): for _, data in channeldata.items():
if data.ecode != ChannelDataEcode.OK.value: if data.ecode != ChannelDataEcode.OK.value:
......
numpy>=1.12, <=1.16.4 ; python_version<"3.5" numpy>=1.12, <=1.16.4 ; python_version<"3.5"
grpcio-tools>=1.28.1 grpcio-tools>=1.28.1
grpcio>=1.28.1 grpcio>=1.28.1
func-timeout==4.3.5 func-timeout>=4.3.5
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册