diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2022-09-29 13:37:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 16:37:55 +0300 |
commit | b0883b791f95a595fae70bcedf3ad0f73c00e258 (patch) | |
tree | 6bfeb975aa6b9ec6325e90246230d01172beb1a6 /redis/client.py | |
parent | cdbc662adcd303d2525f3ace70531aa37a755652 (diff) | |
download | redis-py-b0883b791f95a595fae70bcedf3ad0f73c00e258.tar.gz |
Simplify async timeouts and allowing `timeout=None` in `PubSub.get_message()` to wait forever (#2295)v4.4.0rc2
* Avoid an extra "can_read" call and use timeout directly.
* Remove low-level read timeouts from the Parser, now handled in the Connection
* Allow pubsub.get_message(time=None) to block.
* update Changes
* increase test timeout for robustness
* expand with statement to avoid invoking null context managers.
remove nullcontext
* Remove unused import
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py index 0662a99..75a0dac 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1637,13 +1637,13 @@ class PubSub: if response is not None: yield response - def get_message(self, ignore_subscribe_messages=False, timeout=0): + def get_message(self, ignore_subscribe_messages=False, timeout=0.0): """ Get the next message if one is available, otherwise None. If timeout is specified, the system will wait for `timeout` seconds before returning. Timeout should be specified as a floating point - number. + number, or None, to wait indefinitely. """ if not self.subscribed: # Wait for subscription @@ -1659,7 +1659,7 @@ class PubSub: # so no messages are available return None - response = self.parse_response(block=False, timeout=timeout) + response = self.parse_response(block=(timeout is None), timeout=timeout) if response: return self.handle_message(response, ignore_subscribe_messages) return None |