Skip to content

Commit 5a2c4cd

Browse files
committed
Support for QUIT
Part of redis#1546
1 parent efdba1a commit 5a2c4cd

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

redis/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ class Redis(Commands, object):
707707
'MODULE LIST': lambda r: [pairs_to_dict(m) for m in r],
708708
'OBJECT': parse_object,
709709
'PING': lambda r: str_if_bytes(r) == 'PONG',
710+
'QUIT': bool_ok,
710711
'STRALGO': parse_stralgo,
711712
'PUBSUB NUMSUB': parse_pubsub_numsub,
712713
'RANDOMKEY': lambda r: r and r or None,

redis/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@ def ping(self):
535535
"Ping the Redis server"
536536
return self.execute_command('PING')
537537

538+
def quit(self):
539+
"""Ask the server to close the connection.
540+
https://redis.io/commands/quit
541+
"""
542+
return self.execute_command('QUIT')
543+
538544
def save(self):
539545
"""
540546
Tell the Redis server to save its data to disk,

tests/test_commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ def test_object(self, r):
478478
def test_ping(self, r):
479479
assert r.ping()
480480

481+
def test_quit(self, r):
482+
assert r.quit()
483+
481484
def test_slowlog_get(self, r, slowlog):
482485
assert r.slowlog_reset()
483486
unicode_string = chr(3456) + 'abcd' + chr(3421)

0 commit comments

Comments
 (0)