Skip to content

Commit

Permalink
[Backport 8.x] Fix enabled_cleanup_closed warning (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jan 6, 2025
1 parent a52723a commit 211a0e1
Showing 1 changed file with 7 additions and 1 deletion.
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, TypedDict, Union

Expand Down Expand Up @@ -65,6 +66,11 @@ class RequestKwarg(TypedDict, total=False):
_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 @@ -262,7 +268,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

0 comments on commit 211a0e1

Please sign in to comment.