summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-02-04 11:34:44 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-02-04 11:34:44 +0100
commit0105a8ff79590054e9c30948a1ef7cdb0faa4cef (patch)
tree4851ae192d4b1e6199a043f4b4598d33528cd3a8 /tests
parentd3dbdf8530ec52d42145610cac4e2f981f72b1fa (diff)
downloadtrollius-git-0105a8ff79590054e9c30948a1ef7cdb0faa4cef.tar.gz
Only call _check_resolved_address() in debug mode
* _check_resolved_address() is implemented with getaddrinfo() which is slow * If available, use socket.inet_pton() instead of socket.getaddrinfo(), because it is much faster Microbenchmark (timeit) on Fedora 21 (Python 3.4, Linux 3.17, glibc 2.20) to validate the IPV4 address "127.0.0.1" or the IPv6 address "::1": * getaddrinfo() 10.4 usec per loop * inet_pton(): 0.285 usec per loop On glibc older than 2.14, getaddrinfo() always requests the list of all local IP addresses to the kernel (using a NETLINK socket). getaddrinfo() has other known issues, it's better to avoid it when it is possible.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_events.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test_events.py b/tests/test_events.py
index 4b957d8..8fbba8f 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -1437,6 +1437,10 @@ class EventLoopTestsMixin:
'selector': self.loop._selector.__class__.__name__})
def test_sock_connect_address(self):
+ # In debug mode, sock_connect() must ensure that the address is already
+ # resolved (call _check_resolved_address())
+ self.loop.set_debug(True)
+
addresses = [(socket.AF_INET, ('www.python.org', 80))]
if support.IPV6_ENABLED:
addresses.extend((