Created
January 20, 2023 16:13
-
-
Save datavikingr/9eb1c5cf30b5077f78a50ce489f1377d to your computer and use it in GitHub Desktop.
Python: Try until Success loop
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
# Dead simple try-until-success blob. | |
# I do a lot of OCR based web-scraping for work, and waiting on Java frontends to load consistently breaks my automation. | |
# This bug-fixes the OCR library not finding the object to click, well enough enough to complete the whole pass without restarts. | |
import time | |
while True: | |
try: | |
#some code | |
except: | |
time.sleep(1) | |
continue | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment