diff options
author | Roey Prat <roey.prat@redislabs.com> | 2018-11-05 16:10:51 +0200 |
---|---|---|
committer | Roey Prat <roey.prat@redislabs.com> | 2018-11-07 09:57:25 +0200 |
commit | 5e033f3e716120be992dd26d61b1f7f904331cac (patch) | |
tree | fc0a08ee821ea264ffe883691fd0178902cb00c5 | |
parent | 3e7a1e1f1618b7807d6725ae7537b14e0aff7b7f (diff) | |
download | redis-py-5e033f3e716120be992dd26d61b1f7f904331cac.tar.gz |
Implements CLIENT PAUSE
-rwxr-xr-x | redis/client.py | 13 | ||||
-rw-r--r-- | tests/test_commands.py | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py index 8173ba8..81d8356 100755 --- a/redis/client.py +++ b/redis/client.py @@ -464,7 +464,11 @@ class StrictRedis(object): 'CLIENT KILL': bool_ok, 'CLIENT LIST': parse_client_list, 'CLIENT SETNAME': bool_ok, +<<<<<<< HEAD 'CLIENT UNBLOCK': lambda r: r and int(r) == 1 or False, +======= + 'CLIENT PAUSE': bool_ok, +>>>>>>> 7c3a128... Implements CLIENT PAUSE 'CLUSTER ADDSLOTS': bool_ok, 'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x), 'CLUSTER COUNTKEYSINSLOT': lambda x: int(x), @@ -813,6 +817,15 @@ class StrictRedis(object): args.append(Token.get_token('ERROR')) return self.execute_command(*args) + def client_pause(self, timeout): + """ + Suspend all the Redis clients for the specified amount of time + :param timeout: milliseconds to pause clients + """ + if not isinstance(timeout, (int, long)): + raise RedisError("CLIENT PAUSE timeout must be an integer") + return self.execute_command('CLIENT PAUSE', str(timeout)) + def config_get(self, pattern="*"): "Return a dictionary of configuration based on the ``pattern``" return self.execute_command('CONFIG GET', pattern) diff --git a/tests/test_commands.py b/tests/test_commands.py index f0394d7..abe6143 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -94,6 +94,13 @@ class TestRedisCommands(object): # we don't know which client ours will be assert 'redis_py_test' in [c['name'] for c in clients] + @skip_if_server_version_lt('2.9.50') + def test_client_pause(self, r): + assert r.client_pause(1) + assert r.client_pause(timeout=1) + with pytest.raises(exceptions.RedisError): + r.client_pause(timeout='not an integer') + def test_config_get(self, r): data = r.config_get() assert 'maxmemory' in data |