Skip to content
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

Disconnects do not return ConnectionError for lazy connections #112

Closed
ysobolev opened this issue Dec 14, 2016 · 2 comments
Closed

Disconnects do not return ConnectionError for lazy connections #112

ysobolev opened this issue Dec 14, 2016 · 2 comments

Comments

@ysobolev
Copy link

The documentation for lazy connections says that

If the connection with redis is lost, all commands will raise the ConnectionError exception, to indicate that there's no active connection. However, if the reconnect argument was set to True during the initialization, it will continuosly try to reconnect, in background.

My understanding is that even if reconnect is set to True, I should expect a ConnectionError. This would be useful in the case when it is important to reasonably quickly return an HTTP request with a failure if there are no available redis connections. However, instead the deferred never fires and txredisapi keeps trying to reconnect. For example, examples/twistedweb_server.py will not return an error to a GET request if there is no active redis connection.

@IlyaSkriblovsky
Copy link
Owner

IlyaSkriblovsky commented Dec 15, 2016

I think docs are misleading about this point. reconnect=True is certainly coded to not raise any errors if no connections are active at the moment and is trying to make reconnects invisible to the end user. ConnectionError are only raised for commands that was sent before connection failure but not received responses until disconnected.

I think if you need response from Redis or failure within guaranteed period of time, you can't rely on ConnectionError anyway. Network connection might stall, server might be turned off, wire might be broken and you won't get any response (including failure) until TCP will drop connection by timeout. It seems to me that the only reliable way to guarantee response time is to do timing out on the client side. Deferred.addTimeout() from Twisted 16.5 can probably help.

@ysobolev
Copy link
Author

Thanks! Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants