From da8dcd5520fc798e41966cd5981db8f0a801046c Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Thu, 16 Nov 2023 00:52:24 -0800 Subject: [PATCH] testing: don't spam stderr when the log file is closed --- contrib/pyln-testing/pyln/testing/utils.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index c876c23e378c..7f38f7e66017 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -865,12 +865,16 @@ def __init__(self, socket_path, executor=None, logger=logging, def call(self, method, payload=None, cmdprefix=None, filter=None): id = self.get_json_id(method, cmdprefix) schemas = self.jsonschemas.get(method) - self.logger.debug(json.dumps({ - "id": id, - "method": method, - "params": payload, - "filter": filter, - }, indent=2)) + # Sometimes our log file is closed, don't spam stderr in this case + try: + self.logger.debug(json.dumps({ + "id": id, + "method": method, + "params": payload, + "filter": filter, + }, indent=2)) + except ValueError: + pass # We only check payloads which are dicts, which is what we # usually use: there are some cases which tests [] params,