leporo/tornado-redis — pull request #26 by lessandro (2013-03-11 12:26:55+00:00)
Title: Reset selected db after reconnecting

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).