MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / get_localhost

Function get_localhost

_pydev_bundle/pydev_localhost.py:9–34  ·  view source on GitHub ↗

Should return 127.0.0.1 in ipv4 and ::1 in ipv6 localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work properly and takes a lot of time (had this issue on the pyunit server). Using the IP directly solves the problem.

()

Source from the content-addressed store, hash-verified

7
8
9def get_localhost():
10 """
11 Should return 127.0.0.1 in ipv4 and ::1 in ipv6
12
13 localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work
14 properly and takes a lot of time (had this issue on the pyunit server).
15
16 Using the IP directly solves the problem.
17 """
18 # TODO: Needs better investigation!
19
20 global _cache
21 if _cache is None:
22 try:
23 for addr_info in socket.getaddrinfo("localhost", 80, 0, 0, socket.SOL_TCP):
24 config = addr_info[4]
25 if config[0] == "127.0.0.1":
26 _cache = "127.0.0.1"
27 return _cache
28 except:
29 # Ok, some versions of Python don't have getaddrinfo or SOL_TCP... Just consider it 127.0.0.1 in this case.
30 _cache = "127.0.0.1"
31 else:
32 _cache = "localhost"
33
34 return _cache
35
36
37def get_socket_names(n_sockets, close=False):

Callers 4

test_serverMethod · 0.90
setUpMethod · 0.90
test_editMethod · 0.90
get_socket_namesFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_serverMethod · 0.72
setUpMethod · 0.72
test_editMethod · 0.72