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!
Fixes #2194 by adding an optional
timeout
parameter tois_online()
. Defaults toNone
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 toServerProxy.getPid()
is made (within afinally
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!