From 187bd82f1d5366e0a9137c2af5c5f06589552b1c Mon Sep 17 00:00:00 2001 From: Se7enZ Date: Tue, 17 Sep 2024 12:26:46 +0200 Subject: [PATCH] pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130]) Changelog-Fixed: pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130]) --- contrib/pyln-testing/pyln/testing/fixtures.py | 2 ++ contrib/pyln-testing/pyln/testing/utils.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/pyln-testing/pyln/testing/fixtures.py b/contrib/pyln-testing/pyln/testing/fixtures.py index 13631c1be10d..dede9e88d272 100644 --- a/contrib/pyln-testing/pyln/testing/fixtures.py +++ b/contrib/pyln-testing/pyln/testing/fixtures.py @@ -164,6 +164,8 @@ def bitcoind(directory, teardown_checks): bitcoind.proc.kill() bitcoind.proc.wait() + bitcoind.cleanup_files() + class TeardownErrors(object): def __init__(self): diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index 79e4df0be7a9..061dc652f7e2 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -256,6 +256,14 @@ def kill(self): self.proc.kill() self.proc.wait() + def cleanup_files(self): + """Ensure files are closed.""" + for f in ["stdout_write", "stderr_write", "stdout_read", "stderr_read"]: + try: + getattr(self, f).close() + except Exception: + pass + def logs_catchup(self): """Save the latest stdout / stderr contents; return true if we got anything. """