From 02b0951b1739048b8a8b80a2b406e620e5e17dce Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 29 Mar 2017 10:15:36 -0700 Subject: [PATCH] Disable cleanup closed ssl transports by default --- CHANGES.rst | 2 ++ aiohttp/connector.py | 11 +++++++---- docs/client_reference.rst | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 52b6e9718ff..15507461a82 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,8 @@ Changes - Memory leak with aiohttp.request #1756 +- Disable cleanup closed ssl transports by default. + 2.0.4 (2017-03-27) ------------------ diff --git a/aiohttp/connector.py b/aiohttp/connector.py index dcc7243a96d..375c7342214 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -145,7 +145,7 @@ class BaseConnector(object): def __init__(self, *, keepalive_timeout=sentinel, force_close=False, limit=100, limit_per_host=0, - disable_cleanup_closed=False, loop=None): + enable_cleanup_closed=False, loop=None): if force_close: if keepalive_timeout is not None and \ @@ -182,7 +182,7 @@ def __init__(self, *, keepalive_timeout=sentinel, # start cleanup closed transports task self._cleanup_closed_handle = None - self._cleanup_closed_disabled = disable_cleanup_closed + self._cleanup_closed_disabled = not enable_cleanup_closed self._cleanup_closed_transports = [] self._cleanup_closed() @@ -510,10 +510,13 @@ def __init__(self, *, verify_ssl=True, fingerprint=None, resolve=sentinel, use_dns_cache=True, family=0, ssl_context=None, local_addr=None, resolver=None, keepalive_timeout=sentinel, - force_close=False, limit=100, limit_per_host=0, loop=None): + force_close=False, limit=100, limit_per_host=0, + enable_cleanup_closed=False, loop=None): super().__init__(keepalive_timeout=keepalive_timeout, force_close=force_close, - limit=limit, limit_per_host=limit_per_host, loop=loop) + limit=limit, limit_per_host=limit_per_host, + enable_cleanup_closed=enable_cleanup_closed, + loop=loop) if not verify_ssl and ssl_context is not None: raise ValueError( diff --git a/docs/client_reference.rst b/docs/client_reference.rst index df41d067f2e..108edcc05af 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -691,7 +691,8 @@ TCPConnector use_dns_cache=True, \ family=0, ssl_context=None, conn_timeout=None, \ keepalive_timeout=30, limit=None, \ - force_close=False, loop=None, local_addr=None) + force_close=False, loop=None, local_addr=None, \ + disable_cleanup_closed=True) Connector for working with *HTTP* and *HTTPS* via *TCP* sockets. @@ -765,6 +766,11 @@ TCPConnector .. versionadded:: 0.21 + :param tuple enable_cleanup_closed: Some ssl servers do not properly complete + ssl shutdown process, in that case asyncio leaks ssl connections. + If this parameter is set to True, aiohttp additionally aborts underlining + transport after 2 seconds. It is off by default. + .. attribute:: verify_ssl Check *ssl certifications* if ``True``.