pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])

Changelog-Fixed: pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])
This commit is contained in:
Se7enZ
2024-09-17 12:26:46 +02:00
committed by ShahanaFarooqui
parent 27b4a03419
commit cbe94bcb42
2 changed files with 10 additions and 0 deletions

View File

@@ -164,6 +164,8 @@ def bitcoind(directory, teardown_checks):
bitcoind.proc.kill()
bitcoind.proc.wait()
bitcoind.cleanup_files()
class TeardownErrors(object):
def __init__(self):

View File

@@ -256,6 +256,14 @@ class TailableProc(object):
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.
"""