diff options
author | Andy Isaacson <adi@onbeep.com> | 2014-08-11 16:45:27 -0700 |
---|---|---|
committer | Andy Isaacson <adi@onbeep.com> | 2014-08-12 10:36:25 -0700 |
commit | 5c4273b7ca6b0bac15e9f23e6a9da25af16e9991 (patch) | |
tree | a04bf7f39e43b538de01d38b1ec0a01ddc1c30f3 /redis/client.py | |
parent | eb51763707a85ca1a0aebea502ecfdefe1aa5ad2 (diff) | |
download | redis-py-5c4273b7ca6b0bac15e9f23e6a9da25af16e9991.tar.gz |
add optional "timeout" parameter to pubsub.can_read
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/redis/client.py b/redis/client.py index 74cca86..970953f 100755 --- a/redis/client.py +++ b/redis/client.py @@ -2142,10 +2142,10 @@ class PubSub(object): # previously listening to return command(*args) - def parse_response(self, block=True): + def parse_response(self, block=True, timeout=0): "Parse the response from a publish/subscribe command" connection = self.connection - if not block and not connection.can_read(): + if not block and not connection.can_read(timeout=timeout): return None return self._execute(connection, connection.read_response) @@ -2216,9 +2216,9 @@ class PubSub(object): if response is not None: yield response - def get_message(self, ignore_subscribe_messages=False): + def get_message(self, ignore_subscribe_messages=False, timeout=0): "Get the next message if one is available, otherwise None" - response = self.parse_response(block=False) + response = self.parse_response(block=False, timeout=timeout) if response: return self.handle_message(response, ignore_subscribe_messages) return None |