]> granicus.if.org Git - python/commit
asyncio: Skip getaddrinfo if host is already resolved.
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 17 Dec 2015 00:31:17 +0000 (19:31 -0500)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 17 Dec 2015 00:31:17 +0000 (19:31 -0500)
commitd5c2a6210026834eb3cb7165e470d2cbc3065db8
tree27996fb066b690bde43694bdfd6b50deaed8f630
parent8c084eb77d69ec1527fad943a4031b1b29193e98
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.
Lib/asyncio/base_events.py
Lib/asyncio/proactor_events.py
Lib/asyncio/selector_events.py
Lib/asyncio/test_utils.py
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_proactor_events.py