Skip to content

Commit

Permalink
Dropped: TCPConnector's .resolve, .resolved_hosts, .clear_res…
Browse files Browse the repository at this point in the history
…olved_hosts()` "attrs"" and `resolve` "ctor" parameter #1607
  • Loading branch information
Nikolay Kim committed Feb 8, 2017
1 parent 355857e commit 2ca9466
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 124 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ CHANGES

- Dropped: `aiohttp.web.WebSocketResponse.receive_msg()` #1605

- Dropped: `ServerHttpProtocol.keep_alive_timeout` attr and
`keep-alive`, `keep_alive_on`, `timeout`, `log` ctor parameters #1606
- Dropped: `ServerHttpProtocol.keep_alive_timeout` "attr"" and
`keep-alive`, `keep_alive_on`, `timeout`, `log` "ctor"" parameters #1606

- Dropped: `TCPConnector's`` `.resolve`, `.resolved_hosts`, `.clear_resolved_hosts()` "attrs""
and `resolve` "ctor" parameter #1607
42 changes: 2 additions & 40 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ def __init__(self, *, verify_ssl=True, fingerprint=None,
resolve=sentinel, use_dns_cache=sentinel,
family=0, ssl_context=None, local_addr=None, resolver=None,
conn_timeout=None, keepalive_timeout=sentinel,
force_close=False, limit=20,
loop=None):
force_close=False, limit=20, loop=None):
super().__init__(conn_timeout=conn_timeout,
keepalive_timeout=keepalive_timeout,
force_close=force_close, limit=limit, loop=loop)
Expand All @@ -507,19 +506,8 @@ def __init__(self, *, verify_ssl=True, fingerprint=None,
self._hashfunc = hashfunc
self._fingerprint = fingerprint

if resolve is not sentinel:
warnings.warn(("resolve parameter is deprecated, "
"use use_dns_cache instead"),
DeprecationWarning, stacklevel=2)

if use_dns_cache is not sentinel and resolve is not sentinel:
if use_dns_cache != resolve:
raise ValueError("use_dns_cache must agree with resolve")
_use_dns_cache = use_dns_cache
elif use_dns_cache is not sentinel:
if use_dns_cache is not sentinel:
_use_dns_cache = use_dns_cache
elif resolve is not sentinel:
_use_dns_cache = resolve
else:
_use_dns_cache = True

Expand Down Expand Up @@ -586,32 +574,6 @@ def clear_dns_cache(self, host=None, port=None):
else:
self._cached_hosts.clear()

@property
def resolve(self):
"""Do DNS lookup for host name?"""
warnings.warn((".resolve property is deprecated, "
"use .dns_cache instead"),
DeprecationWarning, stacklevel=2)
return self.use_dns_cache

@property
def resolved_hosts(self):
"""The dict of (host, port) -> (ipaddr, port) pairs."""
warnings.warn((".resolved_hosts property is deprecated, "
"use .cached_hosts instead"),
DeprecationWarning, stacklevel=2)
return self.cached_hosts

def clear_resolved_hosts(self, host=None, port=None):
"""Remove specified host/port or clear all resolve cache."""
warnings.warn((".clear_resolved_hosts() is deprecated, "
"use .clear_dns_cache() instead"),
DeprecationWarning, stacklevel=2)
if host is not None and port is not None:
self.clear_dns_cache(host, port)
else:
self.clear_dns_cache()

@asyncio.coroutine
def _resolve_host(self, host, port):
if is_ip_address(host):
Expand Down
12 changes: 0 additions & 12 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import re
import sys
import time
import warnings
from collections import MutableSequence, namedtuple
from functools import total_ordering
from pathlib import Path
Expand Down Expand Up @@ -534,17 +533,6 @@ def is_ip_address(host):
.format(host, type(host)))


def _get_kwarg(kwargs, old, new, value):
val = kwargs.pop(old, sentinel)
if val is not sentinel:
warnings.warn("{} is deprecated, use {} instead".format(old, new),
DeprecationWarning,
stacklevel=3)
return val
else:
return value


@total_ordering
class FrozenList(MutableSequence):

Expand Down
27 changes: 1 addition & 26 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ TCPConnector
family=0, \
ssl_context=None, conn_timeout=None, \
keepalive_timeout=30, limit=None, \
force_close=False, loop=None, local_addr=None,
resolver=None)
force_close=False, loop=None, local_addr=None)

Connector for working with *HTTP* and *HTTPS* via *TCP* sockets.

Expand Down Expand Up @@ -744,10 +743,6 @@ TCPConnector
The resolver is ``aiohttp.AsyncResolver`` now if
:term:`aiodns` is installed.

:param bool resolve: alias for *use_dns_cache* parameter.

.. deprecated:: 0.17

:param int family: TCP socket family, both IPv4 and IPv6 by default.
For *IPv4* only use :const:`socket.AF_INET`,
for *IPv6* only -- :const:`socket.AF_INET6`.
Expand Down Expand Up @@ -795,12 +790,6 @@ TCPConnector

.. versionadded:: 0.17

.. attribute:: resolve

Alias for :attr:`dns_cache`.

.. deprecated:: 0.17

.. attribute:: cached_hosts

The cache of resolved hosts if :attr:`dns_cache` is enabled.
Expand All @@ -809,12 +798,6 @@ TCPConnector

.. versionadded:: 0.17

.. attribute:: resolved_hosts

Alias for :attr:`cached_hosts`

.. deprecated:: 0.17

.. attribute:: fingerprint

MD5, SHA1, or SHA256 hash of the expected certificate in DER
Expand All @@ -834,14 +817,6 @@ TCPConnector

.. versionadded:: 0.17

.. method:: clear_resolved_hosts(self, host=None, port=None)

Alias for :meth:`clear_dns_cache`.

.. deprecated:: 0.17




ProxyConnector
^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def handler(request):

conn = aiohttp.TCPConnector(
conn_timeout=0.2, resolve=True, loop=loop)
conn.clear_resolved_hosts()
conn.clear_dns_cache()

app = web.Application(loop=loop)
for meth in ('get', 'post', 'put', 'delete', 'head'):
Expand Down
44 changes: 1 addition & 43 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,9 @@ def test_tcp_connector_ctor(loop):
assert conn.verify_ssl
assert conn.fingerprint is None

with pytest.warns(DeprecationWarning):
assert conn.resolve
assert conn.use_dns_cache

assert conn.family == 0

with pytest.warns(DeprecationWarning):
assert conn.resolved_hosts == {}
assert conn.resolved_hosts == {}
assert conn.cached_hosts == {}


def test_tcp_connector_ctor_fingerprint_valid(loop):
Expand All @@ -627,20 +621,6 @@ def test_tcp_connector_fingerprint_invalid(loop):
aiohttp.TCPConnector(loop=loop, fingerprint=invalid)


def test_tcp_connector_clear_resolved_hosts(loop):
conn = aiohttp.TCPConnector(loop=loop)
info = object()
conn._cached_hosts[('localhost', 123)] = info
conn._cached_hosts[('localhost', 124)] = info
conn.clear_dns_cache('localhost', 123)
assert conn.cached_hosts == {('localhost', 124): info}
conn.clear_dns_cache('localhost', 123)
assert conn.cached_hosts == {('localhost', 124): info}
with pytest.warns(DeprecationWarning):
conn.clear_resolved_hosts()
assert conn.cached_hosts == {}


def test_tcp_connector_clear_dns_cache(loop):
conn = aiohttp.TCPConnector(loop=loop)
info = object()
Expand Down Expand Up @@ -968,28 +948,6 @@ def handler(request):
assert r.status == 200


def test_ambiguous_ctor_params(loop):
with pytest.raises(ValueError):
aiohttp.TCPConnector(resolve=True, use_dns_cache=False,
loop=loop)


def test_both_resolve_and_use_dns_cache(loop):
conn = aiohttp.TCPConnector(resolve=True, use_dns_cache=True,
loop=loop)
assert conn.use_dns_cache
with pytest.warns(DeprecationWarning):
assert conn.resolve


def test_both_use_dns_cache_only(loop):
conn = aiohttp.TCPConnector(use_dns_cache=True,
loop=loop)
assert conn.use_dns_cache
with pytest.warns(DeprecationWarning):
assert conn.resolve


def test_default_use_dns_cache(loop):
conn = aiohttp.TCPConnector(loop=loop)
assert conn.use_dns_cache
Expand Down

0 comments on commit 2ca9466

Please sign in to comment.