Skip to content

Commit 187bd82

Browse files
committed
pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])
Changelog-Fixed: pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])
1 parent bfe0557 commit 187bd82

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

contrib/pyln-testing/pyln/testing/fixtures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def bitcoind(directory, teardown_checks):
164164
bitcoind.proc.kill()
165165
bitcoind.proc.wait()
166166

167+
bitcoind.cleanup_files()
168+
167169

168170
class TeardownErrors(object):
169171
def __init__(self):

contrib/pyln-testing/pyln/testing/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ def kill(self):
256256
self.proc.kill()
257257
self.proc.wait()
258258

259+
def cleanup_files(self):
260+
"""Ensure files are closed."""
261+
for f in ["stdout_write", "stderr_write", "stdout_read", "stderr_read"]:
262+
try:
263+
getattr(self, f).close()
264+
except Exception:
265+
pass
266+
259267
def logs_catchup(self):
260268
"""Save the latest stdout / stderr contents; return true if we got anything.
261269
"""

0 commit comments

Comments
 (0)