Skip to content

Commit

Permalink
[3.1] fix resolve cancellation (#2910) (#2931)
Browse files Browse the repository at this point in the history
* fix resolve cancellation

* fixes based on review

* changes based on review

* add changes file

* rename
(cherry picked from commit a7bbaad)

Co-authored-by: Alexander Mohr <thehesiod@users.noreply.github.com>
  • Loading branch information
asvetlov and thehesiod authored Apr 12, 2018
1 parent ae2dbcb commit 68940b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES/2910.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix cancellation broadcast during DNS resolve
12 changes: 6 additions & 6 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,7 @@ async def _resolve_host(self, host, port, traces=None):
await trace.send_dns_resolvehost_start(host)

addrs = await \
asyncio.shield(self._resolver.resolve(host,
port,
family=self._family),
loop=self._loop)
self._resolver.resolve(host, port, family=self._family)
if traces:
for trace in traces:
await trace.send_dns_resolvehost_end(host)
Expand Down Expand Up @@ -813,10 +810,13 @@ async def _create_direct_connection(self, req,
fingerprint = self._get_fingerprint(req)

try:
hosts = await self._resolve_host(
# Cancelling this lookup should not cancel the underlying lookup
# or else the cancel event will get broadcast to all the waiters
# across all connections.
hosts = await asyncio.shield(self._resolve_host(
req.url.raw_host,
req.port,
traces=traces)
traces=traces), loop=self._loop)
except OSError as exc:
# in case of proxy it is not ClientProxyConnectionError
# it is problem of resolving proxy ip itself
Expand Down

0 comments on commit 68940b9

Please sign in to comment.