-
Notifications
You must be signed in to change notification settings - Fork 158
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
Resource Cleanup #233
Comments
When you say "It seems that the redis connections are not being properly handled on exit" you mean when exiting your program (hitting Ctrl-C or because your code crashes) right? If that's the case yeah its normal, I haven't exposed any option to clean up resources once the program ends with aioredis (aiomcache doesn't support that). I'll leave this open because its something that's been annoying me for a while but was working other things I considered more prioritary. Out of curiosity, is it causing any issues to you? |
Yes, I mean hitting Ctrl-C to kill the sanic web server. It doesn't seem to be causing any issues, it just kinda bothers me to see a spew of error messages every time I bring down my server. One suggestion I have that may help with this: Instead of the cache decorator taking a class, it should take an instance of a cache, and use that instance instead of constructing one. Then, that instance can be properly closed upon program exit. For example: redis_cache = RedisCache(host=....) @cached(cache=redis_cache) async def f(...): .... if __name__ == "__main__": .... await redis_cache.close() EDIT: if you are cool with this I can have a go at implementing it. |
Nope, I don't like your proposal for 2 reasons:
There are three situations I can think off that should be covered:
Now, from all above situations, it is obvious that a |
I have implemented the fix in: https://github.com/Quinny/aiocache Just working on updating the tests so they should be warning/error free |
Feel free to open the MR whenever you have it ready :) |
Would you prefer I squash everything into a single commit? Edit: all tests passing with no warnings or errors: Let me know if you want a single commit or if i should break it up and then I will MR |
I do squash commits for the MR usually so no worries |
Call `await cache.close()` to close a pool and its connections
Status update:
|
After aio-libs-abandoned/aioredis-py#239. In the end most of the warnings were noise. With the new aioredis version the amount has been reduced PS: |
Maybe I am using it wrong, but when I tag functions with the
cached
decorator for a redis cache like so:I get the following errors upon exit:
It seems that the redis connections are not being properly handled on exit. Is there currently a way to deal with this?
I am running a sanic app with python3.6 if that makes a difference.
Thanks! Awesome project by the way.
The text was updated successfully, but these errors were encountered: