Add more checks for --min/max-sleep-interval arguments and use more idiomatic naming

This commit is contained in:
Sergey M․ 2016-08-09 03:47:56 +07:00
parent 7aa589a5e1
commit 1ad6b891b2
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D
2 changed files with 13 additions and 8 deletions

View file

@ -343,10 +343,11 @@ class FileDownloader(object):
})
return True
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)
min_sleep_interval = self.params.get('sleep_interval')
if min_sleep_interval:
max_sleep_interval = self.params.get('max_sleep_interval', min_sleep_interval)
print(min_sleep_interval, max_sleep_interval)
sleep_interval = random.uniform(min_sleep_interval, max_sleep_interval)
self.to_screen('[download] Sleeping %s seconds...' % sleep_interval)
time.sleep(sleep_interval)