提交 d0356b6d 编写于 作者: B barrierye

clean up code

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