提交 f32fe486 编写于 作者: C Cleber Rosa

FDDrainer: remove unnecessary lock

This lock doesn't prevent, say, multiple drainers from writing to
a single location.  It's not a cross-instance lock so I fail to
see how it has any purpose at all.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 2f368a60
......@@ -331,7 +331,6 @@ class FDDrainer(object):
# automatically close. This may be used as the detection
# instead.
self._result = result
self._lock = threading.Lock()
self._thread = None
self._logger = logger
self._logger_prefix = logger_prefix
......@@ -356,17 +355,16 @@ class FDDrainer(object):
tmp = os.read(self.fd, 8192)
if tmp == '':
break
with self._lock:
self.data.write(tmp)
if self._verbose:
bfr += tmp
if tmp.endswith('\n'):
for line in bfr.splitlines():
if self._logger is not None:
self._logger.debug(self._logger_prefix, line)
if self._stream_logger is not None:
self._stream_logger.debug('%s\n', line)
bfr = ''
self.data.write(tmp)
if self._verbose:
bfr += tmp
if tmp.endswith('\n'):
for line in bfr.splitlines():
if self._logger is not None:
self._logger.debug(self._logger_prefix, line)
if self._stream_logger is not None:
self._stream_logger.debug('%s\n', line)
bfr = ''
# Write the rest of the bfr unfinished by \n
if self._verbose and bfr:
for line in bfr.splitlines():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册