Add --max-sleep-interval (Closes #9930)

This commit is contained in:
singh-pratyush96 2016-08-04 15:47:22 +05:30 committed by Sergey M․
parent 3a380766d1
commit 065bc35489
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D
4 changed files with 27 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import os
import re
import sys
import time
import random
from ..compat import compat_os_name
from ..utils import (
@ -342,8 +343,10 @@ class FileDownloader(object):
})
return True
sleep_interval = self.params.get('sleep_interval')
if sleep_interval:
sleep_lower_bound = self.params.get('sleep_interval')
if sleep_lower_bound:
sleep_upper_bound = self.params.get('max_sleep_interval', sleep_lower_bound)
sleep_interval = random.uniform(sleep_lower_bound, sleep_upper_bound)
self.to_screen('[download] Sleeping %s seconds...' % sleep_interval)
time.sleep(sleep_interval)