Answers for "try retry python"

1

python try then change something and try again if fails

for i in range(0,100):
    while True:
        try:
            # do stuff
        except SomeSpecificException:
            continue
        break
Posted by: Guest on October-16-2020
0

python retry

import time
def retry(fun, max_tries=10):
    for i in range(max_tries):
        try:
           time.sleep(0.3) 
           fun()
           break
        except Exception:
            continue
Posted by: Guest on May-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language