Block until a result is available for the given key, or until the timeout expires. Returns True if the result is available, or False if the timeout expired. The default implementation polls with exponential backoff, but Redis subclasses provide option to ove
(self, key, timeout=None, backoff=1.15, max_delay=1.0)
| 183 | raise NotImplementedError |
| 184 | |
| 185 | def wait_result(self, key, timeout=None, backoff=1.15, max_delay=1.0): |
| 186 | """ |
| 187 | Block until a result is available for the given key, or until the |
| 188 | timeout expires. Returns True if the result is available, or False if |
| 189 | the timeout expired. |
| 190 | |
| 191 | The default implementation polls with exponential backoff, but Redis |
| 192 | subclasses provide option to override with BLPOP for lower latency |
| 193 | result notification (specify notify_result=True). |
| 194 | """ |
| 195 | deadline = None if timeout is None else time.monotonic() + timeout |
| 196 | delay = 0.05 |
| 197 | while True: |
| 198 | if self.has_data_for_key(key): |
| 199 | return True |
| 200 | if deadline is not None and time.monotonic() >= deadline: |
| 201 | return False |
| 202 | time.sleep(min(delay, max_delay)) |
| 203 | delay *= backoff |
| 204 | |
| 205 | def delete_data(self, key): |
| 206 | """ |