diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-09-01 17:14:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 17:14:55 +0300 |
commit | 42a050c6c0d120104c7433e825e7a798ba411e55 (patch) | |
tree | 26dd64f55b74b9a830620b567139f221b6507081 /redis/commands.py | |
parent | febede19423c95515a7548cd73aa1a90c639ba1f (diff) | |
download | redis-py-42a050c6c0d120104c7433e825e7a798ba411e55.tar.gz |
CLIENT LIST fix to allow multiple client_ids (#1563)
* CLIENT LIST fix to allow multiple client_ids
Support for CLIENT KILL with the USER filter
Part of #1546
* test fix
Diffstat (limited to 'redis/commands.py')
-rw-r--r-- | redis/commands.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/redis/commands.py b/redis/commands.py index c49f043..7f7e00f 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -302,7 +302,7 @@ class Commands: return self.execute_command('CLIENT KILL', address) def client_kill_filter(self, _id=None, _type=None, addr=None, - skipme=None, laddr=None): + skipme=None, laddr=None, user=None): """ Disconnects client(s) using a variety of filter options :param id: Kills a client by its unique ID field @@ -310,7 +310,8 @@ class Commands: 'master', 'slave' or 'pubsub' :param addr: Kills a client by its 'address:port' :param skipme: If True, then the client calling the command - :param laddr: Kills a cient by its 'local (bind) address:port' + :param laddr: Kills a client by its 'local (bind) address:port' + :param user: Kills a client for a specific user name will not get killed even if it is identified by one of the filter options. If skipme is not provided, the server defaults to skipme=True """ @@ -334,6 +335,8 @@ class Commands: args.extend((b'ADDR', addr)) if laddr is not None: args.extend((b'LADDR', laddr)) + if user is not None: + args.extend((b'USER', user)) if not args: raise DataError("CLIENT KILL <filter> <value> ... ... <filter> " "<value> must specify at least one filter") @@ -346,7 +349,7 @@ class Commands: """ return self.execute_command('CLIENT INFO') - def client_list(self, _type=None, client_id=None): + def client_list(self, _type=None, client_id=[]): """ Returns a list of currently connected clients. If type of client specified, only that type will be returned. @@ -362,9 +365,11 @@ class Commands: client_types,)) args.append(b'TYPE') args.append(_type) - if client_id is not None: + if not isinstance(client_id, list): + raise DataError("client_id must be a list") + if client_id != []: args.append(b"ID") - args.append(client_id) + args.append(' '.join(client_id)) return self.execute_command('CLIENT LIST', *args) def client_getname(self): |