Skip to content

Commit 879584b

Browse files
authored
Support for QUIT (redis#1557)
Part of redis#1546
1 parent 9f64c56 commit 879584b

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
@@ -709,6 +709,7 @@ class Redis(Commands, object):
709709
'MODULE LIST': lambda r: [pairs_to_dict(m) for m in r],
710710
'OBJECT': parse_object,
711711
'PING': lambda r: str_if_bytes(r) == 'PONG',
712+
'QUIT': bool_ok,
712713
'STRALGO': parse_stralgo,
713714
'PUBSUB NUMSUB': parse_pubsub_numsub,
714715
'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
@@ -538,6 +538,12 @@ def ping(self):
538538
"Ping the Redis server"
539539
return self.execute_command('PING')
540540

541+
def quit(self):
542+
"""Ask the server to close the connection.
543+
https://redis.io/commands/quit
544+
"""
545+
return self.execute_command('QUIT')
546+
541547
def save(self):
542548
"""
543549
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)