Skip to content

Commit

Permalink
Disable cleanup_closed on cpython <= 3.11.3 (#546)
Browse files Browse the repository at this point in the history
* Disable cleanup_closed on cpython <= 3.11.3

Enabling cleanup closed on python 3.11.1+ and before python 3.11.4 leaks memory relatively quickly (see aio-libs/aiohttp#7252)
  • Loading branch information
ollo69 authored May 16, 2023
1 parent 2fb2ddd commit 6cc01a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/smartthinq_sensors/wideq/core_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import os
import ssl
import sys
from typing import Any, Optional
from urllib.parse import (
ParseResult,
Expand All @@ -36,6 +37,12 @@
# The core version
CORE_VERSION = "coreAsync"

ENABLE_CLEANUP_CLOSED = not (3, 11, 1) <= sys.version_info < (3, 11, 4)
# Enabling cleanup closed on python 3.11.1+ leaks memory relatively quickly
# see https://github.com/aio-libs/aiohttp/issues/7252
# aiohttp interacts poorly with https://github.com/python/cpython/pull/98540
# The issue was fixed in 3.11.4 via https://github.com/python/cpython/pull/104485

# enable logging of auth information
LOG_AUTH_INFO = False

Expand Down Expand Up @@ -130,7 +137,9 @@ def lg_client_session() -> aiohttp.ClientSession:
"""Create an aiohttp client session to use with LG ThinQ."""
context = ssl.create_default_context()
context.set_ciphers(_LG_SSL_CIPHERS)
connector = aiohttp.TCPConnector(enable_cleanup_closed=True, ssl_context=context)
connector = aiohttp.TCPConnector(
enable_cleanup_closed=ENABLE_CLEANUP_CLOSED, ssl_context=context
)
return aiohttp.ClientSession(connector=connector)


Expand Down

0 comments on commit 6cc01a8

Please sign in to comment.