Practice ยท 1 of 1
Reliable enqueue over an unreliable network
Implement enqueue_with_retry(queue, payload, max_attempts=5, base=0.01, cap=0.1):
- call queue.put(payload); ConnectionError means the attempt failed
- between attempts, the backoff ceiling min(cap, base * 2**attempt) must be computed (you may sleep or not โ tests measure calls, not time)
- succeed โ return attempts_used (1-based)
- exhaust all attempts โ raise RuntimeError whose message contains 'exhausted'
queue may be any object with .put โ the test uses one that fails a fixed number of times then succeeds.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Distributed Job System Mini-Project