From 8bc23e50df7b2f4ee4792271a2aad43614caf00f Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 3 Apr 2024 11:11:29 +0530 Subject: [PATCH] qa/vstart_runner: don't let command run after timeout Parameter "timeout" is accepted by LocalRemote.run() but the method doesn't do anything about it besides accepting it. Thus, this parameter has no effect. In LocalRemote.run(), pass this parameter to LocalRemoteProcess.wait() and from this method pass it to subprocess.Popen.communicate(). Thus, command will be terminated by subprocess module at seconds specified by "timeout" parameter. IOW, "timeout" parameter will have an effect. Fixes: https://tracker.ceph.com/issues/65533 Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 8d9dc6f1845c5..b5dbe3c5f97cd 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -233,7 +233,7 @@ class LocalRemoteProcess(object): else: self.stderr.write(err) - def wait(self): + def wait(self, timeout=None): # Null subproc.stdin so communicate() does not try flushing/closing it # again. if self.stdin is not None and self.stdin.closed: @@ -249,7 +249,7 @@ class LocalRemoteProcess(object): else: return - out, err = self.subproc.communicate() + out, err = self.subproc.communicate(timeout=timeout) out, err = rm_nonascii_chars(out), rm_nonascii_chars(err) self._write_stdout(out) self._write_stderr(err) @@ -488,7 +488,7 @@ sudo() { ) if wait: - proc.wait() + proc.wait(timeout) return proc -- 2.39.5