]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2969] fix a logging issue in hammer.py
authorAndrei Pavel <andrei@isc.org>
Fri, 3 Nov 2023 12:40:02 +0000 (14:40 +0200)
committerAndrei Pavel <andrei@isc.org>
Tue, 7 Nov 2023 07:59:22 +0000 (09:59 +0200)
Not all the lines of output were captured when running execute()
with capture=True.

hammer.py

index 24b7d8ac475a38c8b2edc75b88add14b156b9506..cef2c142a41902481eb7c1827efa9f8ca05d125e 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -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.