Getting error while making asynchronous call into es.search() from Flask python API

Error message looks like
Error occurred: '<' not supported between instances of 'AIOHttpConnection' and 'AIOHttpConnection'

Also, at times it throws this error
Error occurred: ConnectionError(Event loop is closed) caused by: RuntimeError(Event loop is closed)

I am using AsyncElasticsearch() with Python Flask 2.0.1

Anyone facing this issue? How to handle multiple asynchronous search REST API requests?

can you share some code as well, that might help to shed some light on the issue?

Thank you!

This issue occurred when using flask library.
Consider the below example:
First time when get_data is invoked via API, it worked fine, return the data. On successive attempts it started failing.

from flask import Flask
from elasticsearch import AsyncElasticsearch

es = AsyncElasticsearch([
    {'host': 'localhost'}
])

async def get_data(self, index, page_from=0, page_size=5):
    body = {"query": {"match_all": {}}}
    return await self.es.search(
        index=index,
        body=body,
        from_=page_from,
        size=page_size
    )

Instead of using from flask import Flask I tried with aioFlask from aioflask import Flask and it worked fine.

Happy to take your suggestion as well.

Also, would like to know if async elasticsearch is compatible with flask 2.x as of now.