leporo / tornado-redis

Asynchronous Redis client that works within Tornado IO loop.
666 stars 162 forks source link

Reset selected db after reconnecting #26

Closed lessandro closed 11 years ago

lessandro commented 11 years ago

In certain cases, when a connection to the redis server is closed and then reopened, the client forgets to select the correct database. This happens because a connection object is reused for reconnections, yet its self.info['db'] value is not reset to the default 0.

Commit edd5fd9 contains a unit test that reproduces the bug. Commit ee57d22 contains the fix -- simply set self.info['db'] to 0 after (re)connecting. This ensures that the client will be able to call select() with the correct database number.

PS: Other test cases in reconnect.py were failing on my machine, I had to fix them before working on this bug (see first two commits).