upstash / redis-py

HTTP based Python Redis Client for Serverless and Edge Functions
https://docs.upstash.com/redis
MIT License
29 stars 3 forks source link

Improve session management of the clients #29

Closed mdumandag closed 1 year ago

mdumandag commented 1 year ago

We had an implementation of the AsyncRedis that is not usable without the async with block. Not all users are going to use it that way, we should allow usages without it as well.

I also found the way the tests written not ideal. We had a single sync and async client and reuse that throughout the test suite. I believe the proper way is to use fixtures per tests and make sure that the clients are closed no matter the result of the test. That resulted in a huge change, but I believe it was worth it. I believe the tests are a bit better right now, as we now have proper test isolation.

Also, the close method was missing from the AsyncRedis, so I added it as well.

TudorZgimbau commented 1 year ago

While this is probably for the better and definitely an improvement, I want to point out why those things were like that in the first place:

Another point that I need to make is, if you are concerned about the test isolation, please don't use a command from the SDK directly in order to test other. It's what I was describing in this pr: https://github.com/upstash/redis-python/pull/16 .

I also liked having a separate test folder for the formatters, but it's just a taste decision.