Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix resolve cancellation #2910

Merged
merged 16 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this shield [1] can be removed, it was put in place just for the situation that you are commenting but taking a look at your MR - and the shield implementation - I was wrong.

[1] https://github.com/aio-libs/aiohttp/blob/master/aiohttp/connector.py#L702

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok was wondering about that, removed

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