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/selector_events.py | |
parent | 8c084eb77d69ec1527fad943a4031b1b29193e98 (diff) | |
download | cpython-d5c2a6210026834eb3cb7165e470d2cbc3065db8.tar.gz cpython-d5c2a6210026834eb3cb7165e470d2cbc3065db8.zip |
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/selector_events.py')
-rw-r--r-- | Lib/asyncio/selector_events.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index a05f81cd9de..5b26631d80d 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -397,8 +397,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): raise ValueError("the socket must be non-blocking") fut = futures.Future(loop=self) try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut.set_exception(err) else: |