3

The server is on a local network.

I tried using a try-except and call one of the server's methods but, if the server is off-line, that takes around 1 second and for my application this is way too long.

Is there a quick way to just check if the server that the ServerProxy is targeting is online?

pdamoc
  • 2,798
  • 15
  • 19
  • You have to wait for the attempted network connection to time out, so it probably won't get any faster (unless you tune the network timeouts of your operating system). – Sven Marnach Nov 01 '11 at 09:38
  • Sven, isn't there a way to check with a custom timeout? – pdamoc Nov 01 '11 at 09:50
  • 1
    http://stackoverflow.com/questions/372365/set-timeout-for-xmlrpclib-serverproxy – plundra Nov 01 '11 at 10:12

1 Answers1

1

I'd do it exactly as you did it. Easier to ask for forgiveness than permission ;) That's common python coding style. The only thing you could probably do is to adjust the network timeout.

If you want to check that reliably, you're on the best way imo. An answer from a server might could delay to about a second, if he is overloaded or something else is bogus with the network.

EDIT:

I'll add that link from plundra to my answer, which explains how to Set timeout for xmlrpclib.ServerProxy .

Community
  • 1
  • 1
naeg
  • 3,944
  • 3
  • 24
  • 29