diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-16 19:31:17 -0500 |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-16 19:31:17 -0500 |
commit | d5c2a6210026834eb3cb7165e470d2cbc3065db8 (patch) | |
tree | 27996fb066b690bde43694bdfd6b50deaed8f630 /Lib/asyncio/proactor_events.py | |
parent | 8c084eb77d69ec1527fad943a4031b1b29193e98 (diff) | |
download | cpython-git-d5c2a6210026834eb3cb7165e470d2cbc3065db8.tar.gz |
asyncio: Skip getaddrinfo if host is already resolved.
getaddrinfo takes an exclusive lock on some platforms, causing clients to queue
up waiting for the lock if many names are being resolved concurrently. Users
may want to handle name resolution in their own code, for the sake of caching,
using an alternate resolver, or to measure DNS duration separately from
connection duration. Skip getaddrinfo if the "host" passed into
create_connection is already resolved.
See https://github.com/python/asyncio/pull/302 for details.
Patch by A. Jesse Jiryu Davis.
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r-- | Lib/asyncio/proactor_events.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 7eac41eec0..14c0659dde 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -441,8 +441,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): def sock_connect(self, sock, address): try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut = futures.Future(loop=self) fut.set_exception(err) |