Skip to content

Commit

Permalink
Disable cleanup closed ssl transports by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 29, 2017
1 parent 216087f commit 02b0951
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Changes

- Memory leak with aiohttp.request #1756

- Disable cleanup closed ssl transports by default.


2.0.4 (2017-03-27)
------------------
Expand Down
11 changes: 7 additions & 4 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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``.
Expand Down

0 comments on commit 02b0951

Please sign in to comment.