Skip to content

Commit

Permalink
Proper handling of HTTP errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarras committed Feb 5, 2019
1 parent 3ebc3a8 commit ac8f2a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dnnlib/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
Expand Down Expand Up @@ -363,6 +363,7 @@ def open_url(url: str, cache_dir: str = None, num_attempts: int = 10, verbose: b
for attempts_left in reversed(range(num_attempts)):
try:
with session.get(url) as res:
res.raise_for_status()
if len(res.content) == 0:
raise IOError("No data received")

Expand Down

0 comments on commit ac8f2a8

Please sign in to comment.