Skip to content

Commit 01518f5

Browse files
authored
download_file: show error + exponential sleep
1 parent 7bf458f commit 01518f5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pythonforandroid/recipe.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,17 @@ def report_hook(index, blksize, size):
191191

192192
# Download item with multiple attempts (for bad connections):
193193
attempts = 0
194+
seconds = 1
194195
while True:
195196
try:
196197
urlretrieve(url, target, report_hook)
197-
except OSError:
198+
except OSError as e:
198199
attempts += 1
199200
if attempts >= 5:
200201
raise
201-
stdout.write('Download failed retrying in a second...')
202-
time.sleep(1)
202+
stdout.write('Download failed: {}; retrying in {} second(s)...'.format(e, seconds))
203+
time.sleep(seconds)
204+
seconds *= 2
203205
continue
204206
break
205207
return target

0 commit comments

Comments
 (0)