diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-09-30 13:35:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 13:35:10 +0300 |
commit | 6c70fcdd10cca7de15175a77824009babfac4417 (patch) | |
tree | a2143f99e26d2304cd433f9f358f0128ef4e1bc7 /redis/commands.py | |
parent | bfc4cd92c8070de9bfa7736ef21b44eb6fe35ed9 (diff) | |
download | redis-py-6c70fcdd10cca7de15175a77824009babfac4417.tar.gz |
CLIENT REPLY support, available since redis 3.2.0 (#1581)
Diffstat (limited to 'redis/commands.py')
-rw-r--r-- | redis/commands.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/redis/commands.py b/redis/commands.py index 427f303..4266f9c 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -376,6 +376,25 @@ class Commands: "Returns the current connection name" return self.execute_command('CLIENT GETNAME') + def client_reply(self, reply): + """Enable and disable redis server replies. + ``reply`` Must be ON OFF or SKIP, + ON - The default most with server replies to commands + OFF - Disable server responses to commands + SKIP - Skip the response of the immediately following command. + + Note: When setting OFF or SKIP replies, you will need a client object + with a timeout specified in seconds, and will need to catch the + TimeoutError. + The test_client_reply unit test illustrates this, and + conftest.py has a client with a timeout. + See https://redis.io/commands/client-reply + """ + replies = ['ON', 'OFF', 'SKIP'] + if reply not in replies: + raise DataError('CLIENT REPLY must be one of %r' % replies) + return self.execute_command("CLIENT REPLY", reply) + def client_id(self): "Returns the current connection id" return self.execute_command('CLIENT ID') |