MCPcopy
hub / github.com/encode/uvicorn / _has_ipv6

Function _has_ipv6

tests/test_main.py:28–40  ·  view source on GitHub ↗
(host: str)

Source from the content-addressed store, hash-verified

26
27
28def _has_ipv6(host: str):
29 sock = None
30 has_ipv6 = False
31 if socket.has_ipv6:
32 try:
33 sock = socket.socket(socket.AF_INET6)
34 sock.bind((host, 0))
35 has_ipv6 = True
36 except Exception: # pragma: no cover
37 pass
38 if sock:
39 sock.close()
40 return has_ipv6
41
42
43@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected