Skip to content

Commit 6167370

Browse files
authored
Fix enabled_cleanup_closed warning (#200)
1 parent e34e8b9 commit 6167370

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

elastic_transport/_node/_http_aiohttp.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import re
2424
import ssl
25+
import sys
2526
import warnings
2627
from typing import Optional, TypedDict, Union
2728

@@ -65,6 +66,11 @@ class RequestKwarg(TypedDict, total=False):
6566
_AIOHTTP_FIXED_HEAD_BUG = False
6667

6768

69+
# Avoid aiohttp enabled_cleanup_closed warning: https://github.com/aio-libs/aiohttp/pull/9726
70+
_NEEDS_CLEANUP_CLOSED_313 = (3, 13, 0) <= sys.version_info < (3, 13, 1)
71+
_NEEDS_CLEANUP_CLOSED = _NEEDS_CLEANUP_CLOSED_313 or sys.version_info < (3, 12, 7)
72+
73+
6874
class AiohttpHttpNode(BaseAsyncNode):
6975
"""Default asynchronous node class using the ``aiohttp`` library via HTTP"""
7076

@@ -262,7 +268,7 @@ def _create_aiohttp_session(self) -> None:
262268
connector=aiohttp.TCPConnector(
263269
limit_per_host=self._connections_per_node,
264270
use_dns_cache=True,
265-
enable_cleanup_closed=True,
271+
enable_cleanup_closed=_NEEDS_CLEANUP_CLOSED,
266272
ssl=self._ssl_context or False,
267273
),
268274
)

0 commit comments

Comments
 (0)