提交 b56b933a 编写于 作者: B barrierye

fix memory leak

上级 d9bb4841
...@@ -634,8 +634,8 @@ class ThreadChannel(Queue.Queue): ...@@ -634,8 +634,8 @@ class ThreadChannel(Queue.Queue):
consumer_cursor = self._consumer_cursors[op_name] consumer_cursor = self._consumer_cursors[op_name]
base_cursor = self._base_cursor base_cursor = self._base_cursor
data_idx = consumer_cursor - base_cursor data_idx = consumer_cursor - base_cursor
resp = self._output_buf[data_idx]
_LOGGER.debug(self._log("{} get data: {}".format(op_name, resp))) resp = None
self._cursor_count[consumer_cursor] -= 1 self._cursor_count[consumer_cursor] -= 1
if consumer_cursor == base_cursor and self._cursor_count[ if consumer_cursor == base_cursor and self._cursor_count[
...@@ -643,7 +643,7 @@ class ThreadChannel(Queue.Queue): ...@@ -643,7 +643,7 @@ class ThreadChannel(Queue.Queue):
# When all the different Ops get the data that data_idx points # When all the different Ops get the data that data_idx points
# to, pop the data from output_buf. # to, pop the data from output_buf.
self._cursor_count.pop(consumer_cursor) self._cursor_count.pop(consumer_cursor)
self._output_buf.pop(0) resp = self._output_buf.pop(0)
self._base_cursor += 1 self._base_cursor += 1
# to avoid cursor overflow # to avoid cursor overflow
if self._base_cursor >= self._reset_max_cursor: if self._base_cursor >= self._reset_max_cursor:
...@@ -654,6 +654,9 @@ class ThreadChannel(Queue.Queue): ...@@ -654,6 +654,9 @@ class ThreadChannel(Queue.Queue):
cursor - self._reset_max_cursor: count cursor - self._reset_max_cursor: count
for cursor, count in self._cursor_count.items() for cursor, count in self._cursor_count.items()
} }
else:
resp = copy.deepcopy(self._output_buf[data_idx])
_LOGGER.debug(self._log("{} get data: {}".format(op_name, resp)))
self._consumer_cursors[op_name] += 1 self._consumer_cursors[op_name] += 1
new_consumer_cursor = self._consumer_cursors[op_name] new_consumer_cursor = self._consumer_cursors[op_name]
...@@ -664,8 +667,7 @@ class ThreadChannel(Queue.Queue): ...@@ -664,8 +667,7 @@ class ThreadChannel(Queue.Queue):
self._cv.notify_all() self._cv.notify_all()
_LOGGER.debug(self._log("multi | {} get data succ!".format(op_name))) _LOGGER.debug(self._log("multi | {} get data succ!".format(op_name)))
# return resp # reference, read only return resp
return copy.deepcopy(resp)
def stop(self): def stop(self):
#TODO #TODO
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册