Created
June 19, 2017 06:39
-
-
Save bearqq/9926187a457ecb2745d72bc17dcaf92a to your computer and use it in GitHub Desktop.
retry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in range(0,retry_times): | |
try: | |
dosomething() | |
break#执行成功,跳出 for | |
except: | |
continue | |
else:#for 执行完毕未跳出,即错误次数超出 | |
raise RetryException() | |
return | |
return "success" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment