Skip to content

Commit

Permalink
dp misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
divi255 committed Apr 12, 2022
1 parent 4b2acb0 commit 1dc3edb
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions lib/eva/datapuller.py
Expand Up @@ -288,18 +288,8 @@ def process_stderr(data):
if data:
logging.error(f'data puller {self.name} {data}')

def decode_line(line):
self.last_activity = time.perf_counter()
try:
return line.decode().strip()
except Exception as e:
logging.error(
f'data puller {self.name} unable to decode data: {e}')
eva.core.log_traceback()
return None

def _t_collect_stream(pipe, q):
for i in iter(pipe.readline, b''):
for i in iter(pipe.readline, ''):
q.put(i)

stdout_q = queue.Queue()
Expand All @@ -320,19 +310,17 @@ def _t_collect_stream(pipe, q):
while self.active:
ns = True
try:
d = stdout_q.get_nowait()
line = stdout_q.get_nowait().strip()
ns = False
line = decode_line(d)
if line is not None:
process_stdout(line)
self.last_activity = time.perf_counter()
process_stdout(line)
except queue.Empty:
pass
try:
d = stderr_q.get_nowait()
line = stderr_q.get_nowait().strip()
ns = False
line = decode_line(d)
if line is not None:
process_stderr(line)
self.last_activity = time.perf_counter()
process_stderr(line)
except queue.Empty:
pass
if ns:
Expand Down

0 comments on commit 1dc3edb

Please sign in to comment.