summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-04-30 17:11:38 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-04-30 17:11:38 +0200
commite5f082e1410d319de124092a8507e8730b9c4270 (patch)
tree69f898ef3fe7531e20a9ba6ef9c16487ee49b44f /scripts
parenta1517915cf0386942d0d0fbc5b101d7ae1c4aa2a (diff)
downloadpsutil-e5f082e1410d319de124092a8507e8730b9c4270.tar.gz
futures: catch exception on result()
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/internal/download_exes.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/scripts/internal/download_exes.py b/scripts/internal/download_exes.py
index ae2604b0..f9839967 100755
--- a/scripts/internal/download_exes.py
+++ b/scripts/internal/download_exes.py
@@ -152,17 +152,27 @@ def rename_27_wheels():
def main(options):
safe_rmtree('dist')
urls = get_file_urls(options)
+ completed = 0
+ exc = None
with concurrent.futures.ThreadPoolExecutor() as e:
fut_to_url = {e.submit(download_file, url): url for url in urls}
for fut in concurrent.futures.as_completed(fut_to_url):
- local_fname = fut.result()
- print("downloaded %-45s %s" % (
- local_fname, bytes2human(os.path.getsize(local_fname))))
+ url = fut_to_url[fut]
+ try:
+ local_fname = fut.result()
+ except Exception as _:
+ exc = _
+ print("error while downloading %s: %s" % (url, exc))
+ else:
+ completed += 1
+ print("downloaded %-45s %s" % (
+ local_fname, bytes2human(os.path.getsize(local_fname))))
# 2 exes (32 and 64 bit) and 2 wheels (32 and 64 bit) for each ver.
expected = len(PY_VERSIONS) * 4
- got = len(fut_to_url)
- if expected != got:
- return exit("expected %s files, got %s" % (expected, got))
+ if expected != completed:
+ return exit("expected %s files, got %s" % (expected, completed))
+ if exc:
+ return exit(1)
rename_27_wheels()