diff options
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index c6a8e4b..b132336 100755 --- a/redis/client.py +++ b/redis/client.py @@ -3054,6 +3054,13 @@ class PubSub(object): return self.handle_message(response, ignore_subscribe_messages) return None + def ping(self, message=None): + """ + Ping the Redis server + """ + message = '' if message is None else message + return self.execute_command('PING', message) + def handle_message(self, response, ignore_subscribe_messages=False): """ Parses a pub/sub message. If the channel or pattern was subscribed to @@ -3068,6 +3075,13 @@ class PubSub(object): 'channel': response[2], 'data': response[3] } + elif message_type == 'pong': + message = { + 'type': message_type, + 'pattern': None, + 'channel': None, + 'data': response[1] + } else: message = { 'type': message_type, @@ -3098,7 +3112,7 @@ class PubSub(object): if handler: handler(message) return None - else: + elif message_type != 'pong': # this is a subscribe/unsubscribe message. ignore if we don't # want them if ignore_subscribe_messages or self.ignore_subscribe_messages: |