def is_server_resolvable():
 socket_timeout = socket.getdefaulttimeout()
 socket.setdefaulttimeout(1)
 try:
  socket.gethostbyname('server')
  return True
 except socket.error:
  return False
 finally:
  socket.setdefaulttimeout(socket_timeout)

def is_server_resolvable ( ) : socket_timeout = socket . getdefaulttimeout ( ) socket . setdefaulttimeout ( 1 ) try : socket . gethostbyname ( 'server' ) return True except socket . error : return False finally : socket . setdefaulttimeout ( socket_timeout )
returns true if server is resolvable .