diff options
author | Roey Prat <roey.prat@redislabs.com> | 2018-11-04 10:26:27 +0200 |
---|---|---|
committer | Roey Prat <roey.prat@redislabs.com> | 2018-11-04 10:29:05 +0200 |
commit | bf15bd6bb6de06d2da8727308bd9d91ff584b514 (patch) | |
tree | d922c2217dc575ebdbff8e1902dc14ab350cf75b | |
parent | 7a8a85245d2e55c2c97290175bd6d6f98976ff5f (diff) | |
download | redis-py-bf15bd6bb6de06d2da8727308bd9d91ff584b514.tar.gz |
Remove reason arg from client_unblock. Use boolean 'error' arg instead.
-rwxr-xr-x | redis/client.py | 15 | ||||
-rw-r--r-- | tests/test_commands.py | 6 |
2 files changed, 9 insertions, 12 deletions
diff --git a/redis/client.py b/redis/client.py index 416d34b..9a16c8e 100755 --- a/redis/client.py +++ b/redis/client.py @@ -717,17 +717,16 @@ class StrictRedis(object): "Sets the current connection name" return self.execute_command('CLIENT SETNAME', name) - def client_unblock(self, client_id, reason=None): + def client_unblock(self, client_id, error=False): """ - Unblocks a connection by its client id - - The ``reason`` argument, if set to ``'error'``, unblocks the client - with a special error message. When set to ``'timeout'`` or if not set, - the client is unblocked using the regular timeout mechanism. + Unblocks a connection by its client id. + If ``error`` is True, unblocks the client with a special error message. + If ``error`` is False (default), the client is unblocked using the + regular timeout mechanism. """ args = ['CLIENT UNBLOCK', int(client_id)] - if reason is not None and isinstance(reason, str): - args.append(reason) + if error: + args.append(Token.get_token('ERROR')) return self.execute_command(*args) def config_get(self, pattern="*"): diff --git a/tests/test_commands.py b/tests/test_commands.py index 724928f..9e77a93 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -67,10 +67,8 @@ class TestRedisCommands(object): def test_client_unblock(self, r): myid = r.client_id() assert not r.client_unblock(myid) - assert not r.client_unblock(myid, reason='TIMEOUT') - assert not r.client_unblock(myid, reason='ERROR') - with pytest.raises(exceptions.ResponseError): - r.client_unblock(myid, reason='foobar') + assert not r.client_unblock(myid, error=True) + assert not r.client_unblock(myid, error=False) @skip_if_server_version_lt('2.6.9') def test_client_getname(self, r): |