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/connection.py | |
parent | eb51763707a85ca1a0aebea502ecfdefe1aa5ad2 (diff) | |
download | redis-py-5c4273b7ca6b0bac15e9f23e6a9da25af16e9991.tar.gz |
add optional "timeout" parameter to pubsub.can_read
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/redis/connection.py b/redis/connection.py index 2d666fb..9afae80 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -555,13 +555,13 @@ class Connection(object): "Pack and send a command to the Redis server" self.send_packed_command(self.pack_command(*args)) - def can_read(self): + def can_read(self, timeout=0): "Poll the socket to see if there's data that can be read." sock = self._sock if not sock: self.connect() sock = self._sock - return bool(select([sock], [], [], 0)[0]) or self._parser.can_read() + return self._parser.can_read() or bool(select([sock], [], [], timeout)[0]) def read_response(self): "Read the response from a previously sent command" |