Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

[Feature request] AsyncElasticsearch should implement an async context manager #48

Closed
amandasystems opened this issue Jul 10, 2018 · 2 comments · Fixed by #49
Closed

Comments

@amandasystems
Copy link
Contributor

It would be nice if AsyncElasticsearch implemented the magic methods (specifically __aenter__() and __aexit__()) to become an async context manager, which would allow code like this:

async with AsyncElasticsearch() as client:
    print(await client.info()) 

and have the session closed.

Happy to implement this similar to how aiohttp has done it if you are interested!

@fxdgear
Copy link
Contributor

fxdgear commented Jul 10, 2018

@AlbinS If you write it I'll review it! :)

Thanks

@amandasystems
Copy link
Contributor Author

@fxdgear Great; I'll start working on it then!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants