Created
November 27, 2018 15:37
-
-
Save spookyahell/2f4b2e6dcfe698b44902220fb804bf49 to your computer and use it in GitHub Desktop.
download relentlessly (even upon error - but sleep inbetween
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
from subprocess import call | |
from time import sleep | |
WAIT_TIME = 5 * 60 | |
def download(): | |
x = call(largs) | |
if x == 1: | |
if args.relentless: | |
try: | |
print('Now sleeping 5 minutes to give kaltura the deserved break...') | |
sleep(WAIT_TIME) | |
except KeyboardInterrupt: | |
pass | |
return download() | |
else: | |
return False | |
elif x == 0: | |
return True, 0 | |
else: | |
return False, x | |
success, exit_code = download() | |
if success is not True: | |
print(f'exited last with exit code {exit_code}') | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment