Tech News
← Back to articles

Retry Loop Retry

read original related products more articles

Retry Loop Retry

Some time ago I lamented that I don’t know how to write a retry loop such that:

it is syntactically obvious that the amount of retries is bounded,

there’s no spurious extra sleep after the last attempt,

the original error is reported if retrying fails,

there’s no code duplication in the loop.

https://matklad.github.io/2023/12/21/retry-loop.html

To recap, we have

fn action () E ! T { ... } fn is_transient_error (err: E) bool { ... }

and we need to write

... continue reading