summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Charriere <nicholascharriere@gmail.com>2017-03-16 12:54:44 -0700
committerGitHub <noreply@github.com>2017-03-16 12:54:44 -0700
commit082f0745421a10bf834759e87ef46c2212698ec4 (patch)
tree5dcacf8fa4ae8af3e797fe5e20b1e982d1c24d51
parent9b92bb726ae348eb3325bfdd6635d79f1b2813e2 (diff)
parent4782f033ba199e7bbc8b020061c3f75879d75c73 (diff)
downloadpymemcache-082f0745421a10bf834759e87ef46c2212698ec4.tar.gz
Merge pull request #145 from renstrom/return-default-value-instead-of-false-when-only-failed-clients
Return default value instead of False when all clients are down
-rw-r--r--pymemcache/client/hash.py2
-rw-r--r--pymemcache/test/test_client_hash.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/pymemcache/client/hash.py b/pymemcache/client/hash.py
index 5e2d6ff..6c9c298 100644
--- a/pymemcache/client/hash.py
+++ b/pymemcache/client/hash.py
@@ -217,7 +217,7 @@ class HashClient(object):
client = self._get_client(key)
if client is None:
- return False
+ return default_val
func = getattr(client, cmd)
args = list(args)
diff --git a/pymemcache/test/test_client_hash.py b/pymemcache/test/test_client_hash.py
index 30b2130..641eaed 100644
--- a/pymemcache/test/test_client_hash.py
+++ b/pymemcache/test/test_client_hash.py
@@ -177,7 +177,7 @@ class TestHashClient(ClientTestMixin, unittest.TestCase):
with pytest.raises(socket.error):
client.get('foo')
- def test_no_servers_left_with_commands(self):
+ def test_no_servers_left_with_commands_return_default_value(self):
from pymemcache.client.hash import HashClient
client = HashClient(
[], use_pooling=True,
@@ -186,6 +186,8 @@ class TestHashClient(ClientTestMixin, unittest.TestCase):
)
result = client.get('foo')
+ assert result is None
+ result = client.set('foo', 'bar')
assert result is False
def test_no_servers_left_with_set_many(self):