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
AsyncElasticsearch client closes event loop when used with PyTest after only 2 queries #2051
Comments
|
This happens because the asyncio event loop when using |
|
Any other solution? I can't create new |
pytest-asyncio 0.23.0 made it much easier to share an event loop for all tests in a class, module, package, or session. See the how-to guides: https://pytest-asyncio.readthedocs.io/en/v0.23.0/how-to-guides/index.html. If that is somehow not an option, you could always use a function-scoped pytest fixture to instantiate a new |
|
Thank you. I have a web based API using FastAPI and |
|
Can you please open a new issue with minimal working code that shows your specific problem and what you want to achieve? It will help me help you. Thanks! |
Elasticsearch version (
bin/elasticsearch --version):7.13.3, in its own container
elasticsearch-pyversion (elasticsearch.__versionstr__):7.14.0
Please make sure the major version matches the Elasticsearch server you are running.
Description of the problem including expected versus actual behavior:
Under PyTest, the Async ElasticSearch client closes its event loop inexplicably.
Steps to reproduce:
For fun, I extended the AsyncElasticsearch class with throwaway code to see what the internal transport loop looked like.
The code is:
The resulting output from a typical PyTest run was disappointing (irrelevant details redacted):
It's not clear to me why the ES client would close the event loop after only two queries when running under PyTest, but works fine for much longer in other (functional) testing or local usage. Nor is it clear what, if anything, I can do about it from within PyTest.
Sorry if this is not the best of bug reports, but I'm stumped.
The text was updated successfully, but these errors were encountered: