ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
752 stars 913 forks source link

Add optional timeout parameter to rosgraph.is_master_online() #2195

Open rr-tom-noble opened 2 years ago

rr-tom-noble commented 2 years ago

Fixes #2194 by adding an optional timeout parameter to is_online(). Defaults to None to preserve existing behaviour.

The blocking code seems to come from deep within xmlrpclib, so the easiest way to add a timeout seems to be using socket.setdefaulttimeout(), which is reset after the call to ServerProxy.getPid() is made (within a finally block to ensure cleanup is performed even when an exception is raised).

Let me know if I should add any tests or apply formatting to the code!