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

Disable cleanup_closed on cpython <= 3.11.3 #546

Merged
merged 2 commits into from
May 16, 2023
Merged
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
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