Skip to content

Commit

Permalink
rosnode: Explicitly handle socket.timeout in rosnode ping (#1517)
Browse files Browse the repository at this point in the history
* Explicitly handle socket.timeout in rosnode ping

* Change error string when handling socket.error
  • Loading branch information
msadowski authored and dirk-thomas committed Aug 3, 2020
1 parent 6c60572 commit d88535b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/rosnode/src/rosnode/__init__.py
Expand Up @@ -333,6 +333,9 @@ def rosnode_ping(node_name, max_count=None, verbose=False):
if verbose:
print("xmlrpc reply from %s\ttime=%fms"%(node_api, dur))
# 1s between pings
except socket.timeout:
print("connection to [%s] timed out"%node_name, file=sys.stderr)
return False
except socket.error as e:
# 3786: catch ValueError on unpack as socket.error is not always a tuple
try:
Expand All @@ -355,7 +358,7 @@ def rosnode_ping(node_name, max_count=None, verbose=False):
continue
print("ERROR: connection refused to [%s]"%(node_api), file=sys.stderr)
else:
print("connection to [%s] timed out"%node_name, file=sys.stderr)
print("connection to [%s] failed"%node_name, file=sys.stderr)
return False
except ValueError:
print("unknown network error contacting node: %s"%(str(e)))
Expand Down

0 comments on commit d88535b

Please sign in to comment.