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

[Backport 8.x] Fix enabled_cleanup_closed warning #201

Merged
merged 9 commits into from
Jan 6, 2025
8 changes: 7 additions & 1 deletion elastic_transport/_node/_http_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import os
import re
import ssl
import sys
import warnings
from typing import Optional, Union

Expand Down Expand Up @@ -61,6 +62,11 @@
_AIOHTTP_FIXED_HEAD_BUG = False


# Avoid aiohttp enabled_cleanup_closed warning: https://github.com/aio-libs/aiohttp/pull/9726
_NEEDS_CLEANUP_CLOSED_313 = (3, 13, 0) <= sys.version_info < (3, 13, 1)
_NEEDS_CLEANUP_CLOSED = _NEEDS_CLEANUP_CLOSED_313 or sys.version_info < (3, 12, 7)


class AiohttpHttpNode(BaseAsyncNode):
"""Default asynchronous node class using the ``aiohttp`` library via HTTP"""

Expand Down Expand Up @@ -258,7 +264,7 @@ def _create_aiohttp_session(self) -> None:
connector=aiohttp.TCPConnector(
limit_per_host=self._connections_per_node,
use_dns_cache=True,
enable_cleanup_closed=True,
enable_cleanup_closed=_NEEDS_CLEANUP_CLOSED,
ssl=self._ssl_context or False,
),
)
Expand Down
Loading