pymemcache
pymemcache copied to clipboard
pymemcache fails if resolving the memcached server fails
Sometime my memcached server is down. When that happens, resolving its address fails on the following line:
info = s.getaddrinfo(host, port, s.AF_UNSPEC, s.SOCK_STREAM,
s.IPPROTO_TCP)
This crashes pymemcache. What should actually happen is to assume it is down, and just marking that as "missed"
I understand that I can use ignore_exc, but this seems like a much more local thing.
Changing this default behavior now is a backwards incompatible change, so we need to be careful about this one. Can you elaborate on why you don't think ignore_exc
is adequate here? Are you asking for the ability to only treat s.getaddrinfo
failing as a miss and not other errors?
ignore_exc
indeed handles the problem correctly.
But having the server down or unreachable doesn't feel like an "exception". I feel like this specific case should be treated as a simple miss.
I agree that it's not obvious and I'm not sure if everyone will agree with me
There are many use cases where someone would like to monitor if their application isn't able to communicate to memcache instead of silently ignoring it, and treating it like a miss by default can easily mask critical issues.
ignore_exc
is already documented in the getting started guide so hopefully that makes it easy for users to choose which behavior they prefer.
https://pymemcache.readthedocs.io/en/latest/getting_started.html#best-practices
#307 has some related discussion.
@yakirsudry do you have any suggestions on what we can do in while ensuring backwards compatibility