diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index f0a4e2336bb6..a9c0f2d9e450 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -215,6 +215,12 @@ def __init__(self, outputDir, verbose=True): # pass it to the log matcher and not print it to stdout). self.log_filter = lambda line: False + def _cleanup_output_files(self): + self.stdout_write.close() + self.stderr_write.close() + self.stdout_read.close() + self.stderr_read.close() + def start(self, stdin=None, stdout_redir=True, stderr_redir=True): """Start the underlying process and start monitoring it. If stdout_redir is false, you have to make sure logs go into @@ -249,6 +255,7 @@ def stop(self, timeout=10): self.proc.kill() self.proc.wait() + self._cleanup_output_files() return self.proc.returncode def kill(self):