summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-20 20:18:11 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-20 20:18:11 +0100
commit9666001e570275fa08a5766639c437d40bbb0545 (patch)
tree174566817e3b11f09cbc5dbdb02dd72558e629fc /module
parentbucket improvement (diff)
downloadpyload-9666001e570275fa08a5766639c437d40bbb0545.tar.xz
improved bucket
Diffstat (limited to 'module')
-rw-r--r--module/network/Bucket.py6
-rw-r--r--module/network/HTTPChunk.py2
-rw-r--r--module/network/HTTPDownload.py7
3 files changed, 9 insertions, 6 deletions
diff --git a/module/network/Bucket.py b/module/network/Bucket.py
index 04b706ff2..434cbe662 100644
--- a/module/network/Bucket.py
+++ b/module/network/Bucket.py
@@ -28,14 +28,16 @@ class Bucket:
self.lock = Lock()
def setRate(self, rate):
+ self.lock.acquire()
self.rate = rate
+ self.lock.release()
def add(self, amount):
self.lock.acquire()
self.drip()
allowable = min(amount, self.rate - self.content)
- if allowable < 3072:
- allowable = 0
+ if allowable > 0:
+ sleep(0.005)
self.content += allowable
self.lock.release()
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index 0c87283f1..509ff3983 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -53,7 +53,7 @@ class HTTPChunk(HTTPBase):
self.speedCalcTime = None
self.speedCalcLen = 0
- self.bufferSize = 16*1024 #tune if performance is poor
+ self.bufferSize = 18*1024 #tune if performance is poor
self.resp = None
def getSpeed(self):
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index d0e2eeb1f..f17e16492 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -22,6 +22,7 @@ from helper import *
from os.path import exists, getsize
from os import remove
#from shutil import move, copyfileobj
+from zlib import decompressobj, MAX_WBITS
from cookielib import CookieJar
@@ -163,10 +164,10 @@ class HTTPDownload():
decompress = lambda data: data
if encoding == "gzip":
- gz = zlib.decompressobj(16+zlib.MAX_WBITS)
+ gz = decompressobj(16+MAX_WBITS)
decompress = lambda data: gz.decompress(data)
if encoding == "deflate":
- df = zlib.decompressobj(-zlib.MAX_WBITS)
+ df = decompressobj(-MAX_WBITS)
decompress = lambda data: df.decompress(data)
fname = "%s.chunk%d" % (self.filename, i)
@@ -271,7 +272,7 @@ if __name__ == "__main__":
import sys
from Bucket import Bucket
bucket = Bucket()
- bucket.setRate(200*1024)
+ bucket.setRate(3000*1024)
bucket = None
url = "http://speedtest.netcologne.de/test_100mb.bin"