Exponential backoff with random jitter. Prevents thundering herd when multiple requests retry simultaneously.
(self, attempt: int)
| 640 | return True |
| 641 | |
| 642 | def jittered_delay_s(self, attempt: int) -> float: |
| 643 | """ |
| 644 | Exponential backoff with random jitter. |
| 645 | Prevents thundering herd when multiple requests retry simultaneously. |
| 646 | """ |
| 647 | base_s = self.config.base_delay_ms / 1000 |
| 648 | max_s = self.config.max_delay_ms / 1000 |
| 649 | jitter_s = self.config.jitter_ms / 1000 |
| 650 | delay = min(base_s * (2 ** (attempt - 1)), max_s) |
| 651 | delay += random.uniform(0, jitter_s) |
| 652 | return delay |
| 653 | |
| 654 | |
| 655 | # ============================================================================= |
no outgoing calls