Trouble using AsyncElasticsearch with RequestsHttpConnection

Viewed 405

I'm running Python 3.8 and getting the following error:

File "/Users/venv/lib/python3.8/site-packages/elasticsearch/_async/transport.py", line 297, in perform_request
status, headers, data = await connection.perform_request(

TypeError: object tuple can't be used in 'await' expression

It would be great if anyone can help me with this issue.

2 Answers
from elasticsearch import AsyncElasticsearch, AIOHttpConnection

Importing connection class AIOHttpConnection and using it in ES client, will fix the issue.

RequestsHttpConnection can only make sync requests.

This class is not compatible with the AsyncElasticsearch client.

The async client at this time can only use AIOHttpConnection connection class.

from elasticsearch import AsyncElasticsearch, AIOHttpConnection

Reference: https://github.com/elastic/elasticsearch-py/issues/1333

Related