fiorix/txredisapi — pull request #40 by dgvncsz0f (2013-02-05 17:57:46+00:00)
Title: WATCH + MGET (or any bulk command) prevents connection from clearing transaction state

The problem:

> conn = yield conn.watch(key)
> reply = yield conn.mget([1, 2])
> conn = yield conn.multi()
> yield conn.exec()

This will result in `conn.transactions` negative. The code that clears
the `inTransaction` flag relies that this number is either 0 (zero) or
positive. Thus, afterwards, the connection has been losted, as the
`inTransaction` will never clear up.

This fix relies on the fact that once `MULTI` command has been issued,
all replies are effectively `QUEUED` until redis receives an `EXEC`
command.

> if self.transactions > 0:
> self.transactions -= len(reply)