-
Notifications
You must be signed in to change notification settings - Fork 313
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
Upgrade ES client to 8.2.0 #1510
Changes from all commits
82cd43f
e7d83cc
5eaf566
3ed00b8
c7d5858
99f8d2b
b4a63fd
4846223
0228326
6f43b03
1f566fb
9bdb361
c73e58c
e4a547e
d3c8c1b
2df742c
17d03e7
ef921df
9627d29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from typing import List, Optional | ||
|
||
import aiohttp | ||
import elasticsearch | ||
import elastic_transport | ||
from aiohttp import BaseConnector, RequestInfo | ||
from aiohttp.client_proto import ResponseHandler | ||
from aiohttp.helpers import BaseTimerContext | ||
|
@@ -168,47 +168,19 @@ def response(self, path): | |
return body | ||
|
||
|
||
class AIOHttpConnection(elasticsearch.AIOHttpConnection): | ||
def __init__( | ||
self, | ||
host="localhost", | ||
port=None, | ||
http_auth=None, | ||
use_ssl=False, | ||
ssl_assert_fingerprint=None, | ||
headers=None, | ||
ssl_context=None, | ||
http_compress=None, | ||
cloud_id=None, | ||
api_key=None, | ||
opaque_id=None, | ||
loop=None, | ||
trace_config=None, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
host=host, | ||
port=port, | ||
http_auth=http_auth, | ||
use_ssl=use_ssl, | ||
ssl_assert_fingerprint=ssl_assert_fingerprint, | ||
# provided to the base class via `maxsize` to keep base class state consistent despite Rally | ||
# calling the attribute differently. | ||
maxsize=kwargs.get("max_connections", 0), | ||
headers=headers, | ||
ssl_context=ssl_context, | ||
http_compress=http_compress, | ||
cloud_id=cloud_id, | ||
api_key=api_key, | ||
opaque_id=opaque_id, | ||
loop=loop, | ||
**kwargs, | ||
) | ||
class RallyAiohttpHttpNode(elastic_transport.AiohttpHttpNode): | ||
def __init__(self, config): | ||
super().__init__(config) | ||
|
||
self._loop = asyncio.get_running_loop() | ||
self._limit = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not be setting
So the code below should read |
||
|
||
self._trace_configs = [trace_config] if trace_config else None | ||
self._enable_cleanup_closed = kwargs.get("enable_cleanup_closed", True) | ||
client_options = config._extras.get("_rally_client_options") | ||
if client_options: | ||
self._trace_configs = client_options.get("trace_config") | ||
self._enable_cleanup_closed = client_options.get("enable_cleanup_closed") | ||
|
||
static_responses = kwargs.get("static_responses") | ||
static_responses = client_options.get("static_responses") | ||
self.use_static_responses = static_responses is not None | ||
|
||
if self.use_static_responses: | ||
|
@@ -223,21 +195,22 @@ def __init__( | |
self._request_class = aiohttp.ClientRequest | ||
self._response_class = RawClientResponse | ||
|
||
async def _create_aiohttp_session(self): | ||
if self.loop is None: | ||
self.loop = asyncio.get_running_loop() | ||
|
||
def _create_aiohttp_session(self): | ||
if self.use_static_responses: | ||
connector = StaticConnector(limit=self._limit, enable_cleanup_closed=self._enable_cleanup_closed) | ||
else: | ||
connector = aiohttp.TCPConnector( | ||
limit=self._limit, use_dns_cache=True, ssl_context=self._ssl_context, enable_cleanup_closed=self._enable_cleanup_closed | ||
limit=self._limit, | ||
use_dns_cache=True, | ||
# May need to be just ssl=self._ssl_context | ||
ssl_context=self._ssl_context, | ||
Comment on lines
+205
to
+206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please do that. Using |
||
enable_cleanup_closed=self._enable_cleanup_closed, | ||
) | ||
|
||
self.session = aiohttp.ClientSession( | ||
headers=self.headers, | ||
auto_decompress=True, | ||
loop=self.loop, | ||
loop=self._loop, | ||
cookie_jar=aiohttp.DummyCookieJar(), | ||
request_class=self._request_class, | ||
response_class=self._response_class, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please assign
self._loop
toNone
here and only callasyncio.get_running_loop
in_create_aiohttp_session
like elastic-transport does?https://sethmlarson.dev/blog/flask-async-views-and-async-globals explains why it's important to wait before calling this function.