diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2010-08-18 11:19:27 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2010-08-18 11:19:27 -0700 |
commit | cc614423129e156b38ac0ba789287f60838234df (patch) | |
tree | 1c31685376cb18dc908b03034771c9555cba02bb /redis/client.py | |
parent | 9097ca4ae3ec0f99ea4a96392b4126d883066046 (diff) | |
download | redis-py-cc614423129e156b38ac0ba789287f60838234df.tar.gz |
added a shutdown command. fixes #58. no tests for this because it would be impossible to restart the redis instance being tested against.
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py index b0352fa..e6c5cf8 100644 --- a/redis/client.py +++ b/redis/client.py @@ -448,6 +448,17 @@ class Redis(threading.local): self.connection = self.get_connection( host, port, db, password, socket_timeout) + def shutdown(self): + "Shutdown the server" + if self.subscribed: + raise RedisError("Can't call 'shutdown' from a pipeline'") + try: + self.execute_command('SHUTDOWN') + except ConnectionError: + # a ConnectionError here is expected + return + raise RedisError("SHUTDOWN seems to have failed.") + #### SERVER INFORMATION #### def bgrewriteaof(self): |