5 ms·
Forgive me because I have used a similar idom when dealing with io. I do something like: for i=0; i<3; i++: try: doSomeIoWork() catch: i
by confusedcoder 7y ago
Forgive me because I have used a similar idom when dealing with io.
I do something like:
for i=0; i<3; i++:
try:
doSomeIoWork()
catch:
if i<3:
# maybe some network/disk issues retry?
sleep SOME_TIME * i;
continue;
else:
# tried too many times now quit
raise
Am I doing something stupid here?
- kamaal 7y agoNothing. Probably the original developer was trying to do the same thing. There is always a context to what some one is doing.
- pault 7y agoI think the try/catch block is confusing commenters; it's irrelevant to the control flow in this case. You could consider it equivalent to: for i=0; i<3; i++: doSomething(); if i<3: continue; else: break;
- hackinthebochs 7y agoWell the continue isn't doing any work for you since the else clause prevents the raise from being called.