[downloader/common] Fix possible negative sleep time in slow_down()
authorSyxbEaEQ2 <SyxbEaEQ2@users.noreply.github.com>
Wed, 6 Aug 2014 18:53:04 +0000 (20:53 +0200)
committerSyxbEaEQ2 <SyxbEaEQ2@users.noreply.github.com>
Wed, 6 Aug 2014 18:53:04 +0000 (20:53 +0200)
youtube_dl/downloader/common.py

index 6404e19285080f1f37c952bd0dfc47bbf38b0622..33ebbf6b44e8de601b9c7ddb01f7c2d59cae5be0 100644 (file)
@@ -157,7 +157,7 @@ class FileDownloader(object):
             return
         speed = float(byte_counter) / elapsed
         if speed > rate_limit:
-            time.sleep((byte_counter / rate_limit) - elapsed)
+            time.sleep(max((byte_counter / rate_limit) - elapsed, 0))
 
     def temp_name(self, filename):
         """Returns a temporary filename for the given filename."""