Skip to content

Commit

Permalink
[downloader/common] Improve rate limit (#21301)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and meunierd committed Feb 13, 2020
1 parent 5441000 commit a8bc06b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion youtube_dl/downloader/common.py
Expand Up @@ -176,7 +176,9 @@ def slow_down(self, start_time, now, byte_counter):
return
speed = float(byte_counter) / elapsed
if speed > rate_limit:
time.sleep(max((byte_counter // rate_limit) - elapsed, 0))
sleep_time = float(byte_counter) / rate_limit - elapsed
if sleep_time > 0:
time.sleep(sleep_time)

def temp_name(self, filename):
"""Returns a temporary filename for the given filename."""
Expand Down

0 comments on commit a8bc06b

Please sign in to comment.