From e87da8b3b5125d5895c2208442a51a66a70c7110 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Fri, 6 Dec 2024 10:25:31 +0100 Subject: [PATCH] rosnode: Fix unclosed socket in rosnode_ping command --- tools/rosnode/src/rosnode/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/rosnode/src/rosnode/__init__.py b/tools/rosnode/src/rosnode/__init__.py index 91b3e983b4..7377f002d9 100644 --- a/tools/rosnode/src/rosnode/__init__.py +++ b/tools/rosnode/src/rosnode/__init__.py @@ -359,6 +359,7 @@ def rosnode_ping(node_name, max_count=None, verbose=False, skip_cache=False): if verbose: print("node url has changed from [%s] to [%s], retrying to ping"%(node_api, new_node_api)) node_api = new_node_api + node.__exit__() node = ServerProxy(node_api) continue print("ERROR: connection refused to [%s]"%(node_api), file=sys.stderr) @@ -373,7 +374,9 @@ def rosnode_ping(node_name, max_count=None, verbose=False, skip_cache=False): time.sleep(1.0) except KeyboardInterrupt: pass - + finally: + node.__exit__() + if verbose and count > 1: print("ping average: %fms"%(acc/count)) return True