Skip to content

Commit ae4b7f0

Browse files
pquentingithub-actions[bot]
authored andcommitted
Fix enabled_cleanup_closed warning (#200)
(cherry picked from commit 6167370)
1 parent 577375f commit ae4b7f0

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, Union
2728

@@ -61,6 +62,11 @@
6162
_AIOHTTP_FIXED_HEAD_BUG = False
6263

6364

65+
# Avoid aiohttp enabled_cleanup_closed warning: https://github.com/aio-libs/aiohttp/pull/9726
66+
_NEEDS_CLEANUP_CLOSED_313 = (3, 13, 0) <= sys.version_info < (3, 13, 1)
67+
_NEEDS_CLEANUP_CLOSED = _NEEDS_CLEANUP_CLOSED_313 or sys.version_info < (3, 12, 7)
68+
69+
6470
class AiohttpHttpNode(BaseAsyncNode):
6571
"""Default asynchronous node class using the ``aiohttp`` library via HTTP"""
6672

@@ -258,7 +264,7 @@ def _create_aiohttp_session(self) -> None:
258264
connector=aiohttp.TCPConnector(
259265
limit_per_host=self._connections_per_node,
260266
use_dns_cache=True,
261-
enable_cleanup_closed=True,
267+
enable_cleanup_closed=_NEEDS_CLEANUP_CLOSED,
262268
ssl=self._ssl_context or False,
263269
),
264270
)

0 commit comments

Comments
 (0)