projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
59ca17b
)
[downloader/common] Improve rate limit (#21301)
author
Sergey M․
<dstftw@gmail.com>
Tue, 4 Jun 2019 20:06:35 +0000
(
03:06
+0700)
committer
Sergey M․
<dstftw@gmail.com>
Tue, 4 Jun 2019 20:06:35 +0000
(
03:06
+0700)
youtube_dl/downloader/common.py
patch
|
blob
|
history
diff --git
a/youtube_dl/downloader/common.py
b/youtube_dl/downloader/common.py
index 646d7f7795cc47c281db3033fa3a9df87a646ed2..1cdba89cd9b093c1cc45071d34e307028aac02ea 100644
(file)
--- a/
youtube_dl/downloader/common.py
+++ b/
youtube_dl/downloader/common.py
@@
-176,7
+176,9
@@
class FileDownloader(object):
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."""