fix(memcached): let clear_path raise connection errors - #196
Merged
Merged
Conversation
clear_path() caught every exception and returned 0, so a connection failure looked like "nothing to clear", while delete() and the other methods let the error through. Closes #177
This was referenced Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #177.
Problem
MemcachedBackend.clear_path()wrapped its delete inexcept Exception: return 0. A connection failure was therefore reported as "nothing to clear", whiledelete()and every other method let the error through.Change
Drop the
try/except.clear_path()now reports errors the same waydelete()does.Note on pymemcache's own error handling
HashClient(ignore_exc=False, defaultretry_attempts=2,retry_timeout=1,dead_timeout=60) behaves like this:OSErroron the first failed call.None/False) without raising.MemcacheError("All servers seem to be down right now").This PR only removes the extra layer in
clear_path(), which also hid the first error and the "all servers down" one. The silent defaults during the retry window affect every method, and are tracked in #197.Tests
test_memcached_clear_path_raises_when_the_server_is_unreachablepoints the backend at a closed port and expectsConnectionRefusedError. It needs no live server.test_memcached_clear_path_exceptionasserted that the error was swallowed. It is now..._propagates_client_errors, and expects the error.exceptrestored, exactly these two tests fail.CACHEX_REQUIRE_LIVE_SERVERS=1): 849 passed, 100% coverage.