From: Fredrik Tolf Date: Mon, 27 Jul 2020 12:04:28 +0000 (+0200) Subject: getmanga: Introduce a bit of retry logic in opening pages. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=8fdbf188fe3d22ca3af782d1502de1ec7ddfe1d7;p=automanga.git getmanga: Introduce a bit of retry logic in opening pages. --- diff --git a/getmanga b/getmanga index aa83359..3ea50d3 100755 --- a/getmanga +++ b/getmanga @@ -117,7 +117,20 @@ def download(mng, tdir, pattern): msg(2, "%s exists, skipping", nm) continue msg(1, "getting %s...", nm) - with page.open() as fp: + retries = 0 + while True: + try: + fp = page.open() + break + except OSError as error: + if retries < 5: + sys.stderr.write("getmanga: warning: error when getting %s: %s\n" % (nm, error)) + retries += 1 + time.sleep(60) + else: + sys.stderr.write("getmanga: error when getting %s: %s\n" % (nm, error)) + sys.exit(1) + with fp: with open(path, "wb") as out: done = False try: