From 193e50363dd9b8df29062e9830c27ef4b153f083 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 18 May 2023 09:52:10 -0400 Subject: [PATCH] qa/tasks/vstart_runner: allow writing to command's stdin There's no technical reason to disallow this. The original intent was to avoid deadlocks but this possibility is already present when interacting with a teuthology RemoteProcess. Avoiding it only for local processes does not make sense. Signed-off-by: Patrick Donnelly --- qa/tasks/vstart_runner.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index df4886fb66975..6549dcaf11bee 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -204,6 +204,7 @@ class LocalRemoteProcess(object): def __init__(self, args, subproc, check_status, stdout, stderr, usr_args): self.args = args self.subproc = subproc + self.stdin = subproc.stdin self.stdout = stdout self.stderr = stderr self.usr_args = usr_args @@ -233,6 +234,12 @@ class LocalRemoteProcess(object): self.stderr.write(err) def wait(self): + # Null subproc.stdin so communicate() does not try flushing/closing it + # again. + if self.stdin is not None and self.stdin.closed: + self.stdin = None + self.subproc.stdin = None + if self.finished: # Avoid calling communicate() on a dead process because it'll # give you stick about std* already being closed @@ -285,16 +292,6 @@ class LocalRemoteProcess(object): else: log.debug(f"kill: already terminated ({self.usr_args})") - @property - def stdin(self): - class FakeStdIn(object): - def __init__(self, mount_daemon): - self.mount_daemon = mount_daemon - - def close(self): - self.mount_daemon.kill() - - return FakeStdIn(self) class LocalRemote(RemoteShell): -- 2.39.5