2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#2969] fix a logging issue in hammer.py

Not all the lines of output were captured when running execute()
with capture=True.
This commit is contained in:
Andrei Pavel
2023-11-03 14:40:02 +02:00
parent cafead21a9
commit 0deb3df1ef

View File

@@ -375,7 +375,8 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
if capture:
output = ''
t0 = time.time()
# repeat until process is running or timeout not occurred
# Repeat until the process has stopped and there are no more lines
# to read, or until the timeout is up.
while True:
line = p.stdout.readline()
if line:
@@ -387,7 +388,7 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
if log_file_path:
log_file.write(line)
t1 = time.time()
if p.poll() is not None or (timeout is not None and timeout < t1 - t0):
if p.poll() is not None and not line or (timeout is not None and timeout < t1 - t0):
break
# If no exitcode yet, ie. process is still running then it means that timeout occurred.