MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / test_connection

Function test_connection

verl/scripts/diagnose.py:50–67  ·  view source on GitHub ↗

Simple connection test

(name, url, timeout=10)

Source from the content-addressed store, hash-verified

48
49
50def test_connection(name, url, timeout=10):
51 """Simple connection test"""
52 urlinfo = urlparse(url)
53 start = time.time()
54 try:
55 socket.gethostbyname(urlinfo.netloc)
56 except Exception as e:
57 print("Error resolving DNS for {}: {}, {}".format(name, url, e))
58 return
59 dns_elapsed = time.time() - start
60 start = time.time()
61 try:
62 _ = urlopen(url, timeout=timeout)
63 except Exception as e:
64 print("Error open {}: {}, {}, DNS finished in {} sec.".format(name, url, e, dns_elapsed))
65 return
66 load_elapsed = time.time() - start
67 print("Timing for {}: {}, DNS: {:.4f} sec, LOAD: {:.4f} sec.".format(name, url, dns_elapsed, load_elapsed))
68
69
70def check_python():

Callers 1

check_networkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected