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
Add warning about unclosed AsyncClient #871
Comments
Hi @kamilglod Can you share what the UX for this in aiohttp looks like? (eg maybe a snippet of an interactive interpreter session…) I'm just wondering if this would actually provide value, or just add noise when shutting down an interpreter (which should force-close any dangling resources anyway, no?). |
@florimondmanca closing all connections sounds fine but question is whether it is technically doable as |
Thanks, the REPL snippet is useful. An implementation similar to aiohttp is technically possible — ie log a warning but don’t attempt to close the client (notably because, as you said, it’s an async operation). One bit to keep in mind is that this would need to be async library agnostic (asyncio/trio) - so the check needs to be deferred to the async backends at some point - so this doesn’t seem like a trivial addition. But if you’d like to give it a shot feel free to. :) |
@florimondmanca If anyone is not working on it. I would like to give it a try. 😄 |
I was setting up the project locally and in the step of installing dependencies. Should it explicitly mention that
Or is it just me that went ahead creating a virtual env and running the command |
@Pradhvan do you mind if I take this? |
@florimondmanca should we add the similar check for |
@cdeler yes 😄 |
…ich is too quiet) to RuntimeWarning (encode#871)
…ich is too quiet) to UserWarning (encode#871)
All over the AsyncClient invocation is made using context manager or with try-finally block
All over the AsyncClient invocation is made using context manager or with try-finally block
…ich is too quiet) to UserWarning (encode#871)
* Made Client and AsyncClient checking for being closed in __del__ (#871) * Changed the AsyncClient closing warning type from ResourceWarning (which is too quiet) to UserWarning (#871) * Fixed tests and client's __exit__ and __aexit__ after the difficult merge (#871) * Update test_proxies.py * Update test_proxies.py Co-authored-by: Tom Christie <tom@tomchristie.com>
It would be nice to have an info about some unclosed
AsyncClient()
instance. Here is an example how it is implemented in aiohttp: https://github.com/aio-libs/aiohttp/blob/693ed0cce0c67646f8df18c93e448d10782c2811/aiohttp/client.py#L268-L286The text was updated successfully, but these errors were encountered: