3 ms·
That’s not taking exceptions into consideration. There is actually a way to do it with loops. for attempt in retry(timeout=10, ..) with attempt:
by Too 4y ago
That’s not taking exceptions into consideration.
There is actually a way to do it with loops.
for attempt in retry(timeout=10, ..)
with attempt:
do_stuff()
Assuming you have a clever implementation of the retry function. IIRC tenacity has one that works like this.
- bvrmn 4y agoIt's better to make exception handling explicit. It has the same semantic complexity comparing to passing possible good exception types into retry or attempt. Inline loop logic to decide if iteration is successful can be tricky.