MCPcopy Create free account
hub / github.com/Emmimal/control-layer / jittered_delay_s

Method jittered_delay_s

control_layer.py:642–652  ·  view source on GitHub ↗

Exponential backoff with random jitter. Prevents thundering herd when multiple requests retry simultaneously.

(self, attempt: int)

Source from the content-addressed store, hash-verified

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# =============================================================================

Callers 2

runMethod · 0.80

Calls

no outgoing calls

Tested by 1