def test_memcached(host, port):
 try:
  s = socket.socket()
  s.connect((host, port))
  return True
 except Exception as exc:
  log.critical(('Failed to connect to memcached (%r): %s' % ((host, port), exc)))
  return False
 finally:
  s.close()

def test_memcached ( host , port ) : try : s = socket . socket ( ) s . connect ( ( host , port ) ) return True except Exception as exc : log . critical ( ( 'Failed to connect to memcached (%r): %s' % ( ( host , port ) , exc ) ) ) return False finally : s . close ( )
connect to memcached .