eric-haibin-lin commented on a change in pull request #11181: [MXNET-525] Add
retry logic to download functions to fix flaky tests
URL: https://github.com/apache/incubator-mxnet/pull/11181#discussion_r193616273
##########
File path: python/mxnet/test_utils.py
##########
@@ -1411,12 +1416,21 @@ def download(url, fname=None, dirname=None,
overwrite=False):
logging.info("%s exists, skipping download", fname)
return fname
- r = requests.get(url, stream=True)
- assert r.status_code == 200, "failed to open %s" % url
- with open(fname, 'wb') as f:
- for chunk in r.iter_content(chunk_size=1024):
- if chunk: # filter out keep-alive new chunks
- f.write(chunk)
+ while (retries+1 > 0):
+ try:
+ r = requests.get(url, stream=True)
+ assert r.status_code == 200, "failed to open %s" % url
+ with open(fname, 'wb') as f:
+ for chunk in r.iter_content(chunk_size=1024):
+ if chunk: # filter out keep-alive new chunks
+ f.write(chunk)
+ break
+ except Exception as e:
+ retries -= 1
+ if (retries <= 0):
Review comment:
no need for parentheses in python. pls remove
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services