You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
The ping() method should not crash in the async version of the Elasticsearch client, and behave like the synchronous version of the client. This async version returns True properly, but raises instead of returning False.
Expected behavior
It should return a boolean like the synchronous version:
$ python3
Python 3.8.2 (default, Feb 25 2020, 13:04:52)
[GCC 9.2.1 20200224] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import elasticsearch
>>> es = elasticsearch.Elasticsearch("127.0.0.1:9")
>>> es.ping()
False
>>>
Actual behavior
The async version raises instead of returning False:
$ python3 -m asyncio
asyncio REPL 3.8.2 (default, Feb 25 2020, 13:04:52)
[GCC 9.2.1 20200224] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> import elasticsearch_async
>>> es = elasticsearch_async.AsyncElasticsearch("127.0.0.1:9")
>>> await es.ping()
Traceback (most recent call last):
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
raise exceptions[0]
File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connect
return await fut
File "/usr/lib/python3.8/asyncio/selector_events.py", line 526, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 9)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/home/venv/lib/python3.8/site-packages/elasticsearch_async/connection.py", line 98, in perform_request
response = yield from self.session.request(method, url, data=body, headers=headers)
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
conn = await self._connector.connect(
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
_, proto = await self._create_direct_connection(
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
raise last_exc
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/home/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:9 ssl:default [Connect call failed ('127.0.0.1', 9)]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "<console>", line 1, in <module>
File "/home/home/venv/lib/python3.8/site-packages/elasticsearch_async/transport.py", line 149, in main_loop
status, headers, data = yield from connection.perform_request(
File "/home/home/venv/lib/python3.8/site-packages/elasticsearch_async/connection.py", line 111, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(Cannot connect to host 127.0.0.1:9 ssl:default [Connect call failed ('127.0.0.1', 9)]) caused by: ClientConnectorError(Cannot connect to host 127.0.0.1:9 ssl:default [Connect call failed ('127.0.0.1', 9)])
>>>
The ping() method should not crash in the async version of the Elasticsearch client, and behave like the synchronous version of the client. This async version returns True properly, but raises instead of returning False.
Expected behavior
It should return a boolean like the synchronous version:
Actual behavior
The async version raises instead of returning False:
Environment
Nothing is listening on port 9.
Installed packages:
The text was updated successfully, but these errors were encountered: