-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
fix: close RedisStore client in case the with_client classmethod is used #3111
Conversation
Note that close_connection_pool is required
…manually or not Co-authored-by: Janek Nouvertné <provinzkraut@posteo.de>
Co-authored-by: Janek Nouvertné <provinzkraut@posteo.de>
you're reviewing / holding my hand faster than I can type :) |
Sorry 😬 |
no worries that was fun, I almost wondered if you were not a LLM at sone point 🤣 |
I do wonder that too at times. Aren't we all just fancy LLMs at some level? 👀 |
…ation decides to handle to close or not
that kind of would be Nick Bolstrom's theory in "Are you living in a computer simulation?" |
…sn't recognized, we use types-redis
Added some small notes on the test since its setup is rather cumbersome
I might have introduced some flakiness :) |
ok in fact it's just the test I added doesnt integrate well in the suite, need to find a way to see how to keep it without issues |
…ve all removing the Redis sync instance created there that was never closed
… with existing suite
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3111 +/- ##
=======================================
Coverage 98.26% 98.26%
=======================================
Files 320 320
Lines 14405 14417 +12
Branches 2317 2319 +2
=======================================
+ Hits 14155 14167 +12
Misses 109 109
Partials 141 141 ☔ View full report in Codecov by Sentry. |
ok I removed my initial test from the mcve that passes with the change made to the lifespan, reason is twofold. one, as you can notice in the suite, all instances where with_client is used are patched, so if there is a test to be made, one has to follow the same rule or we may end up having unclosed ressources: I therefore think this test is problematic: litestar/tests/unit/test_stores.py Lines 242 to 245 in 323e23e
because it doesnt patch the with_client and will leave things unclosed, the other line is fine Also, I modified the redis_client fixture: https://github.com/litestar-org/litestar/pull/3111/files#diff-e52e4ddd58b7ef887ab03c04116e676f6280b824ab7469d5d3080e5cba4f2128L307-R315 the previous one is problematic because it uses a sync redis instance to flushall and never closes it, one can just use the async redis instance from the fixture and flushall in the finally for the same effect without the unintended consequences, wdyt ? |
I think the proper fix would be to close the sync Also, I'm surprised that calling |
so @provinzkraut I sent a PR fixing the fixture think properly I think here: #3117 questions now on this one:
|
… with_client will lose the automatic handling
…n on its own now but most likely will please the CI
Co-authored-by: Janek Nouvertné <provinzkraut@posteo.de>
I think it should be ready, I'm not pleased with the fixtures as-is to be fair, so I reverted my changes on this part but that shouldn't prevent the PR to be looked at ;) |
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3111 |
Description
WIP, it doesn't pass the test I added from the mvce in the issue (this one could certainly be simplified) so my impleentation has obviously an issue.
I made the
RedisStore
an async context manager, I can see the_on_shutdon
method being hit, but the_redis
client is still not closed or it doesnt exists.from your comment here:
https://discord.com/channels/919193495116337154/1152626430295933060/1207016578823102565
Closes
Fixes #3083