From e34e89ba091aa2feaf93802787799e7760039eac Mon Sep 17 00:00:00 2001 From: Thomas Keck Date: Fri, 12 Mar 2010 21:58:32 +0100 Subject: Working!! --- proxy.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/proxy.py b/proxy.py index 77356f5..d8c8e75 100644 --- a/proxy.py +++ b/proxy.py @@ -9,15 +9,16 @@ except ImportError: ENDPOINTS = [ ('10.2.2.11', 8888), - ('10.3.1.2', 8888), + # ('10.3.1.2', 8888), ('10.1.1.156', 8888), ] #minimum entity size to start a paralel fetch KB = 1024 -MINIMAL_SIZE = 512 * KB -BLOCKSIZE_FETCH = 2048 * KB -BLOCKSIZE_STEP = 512 * KB +THRESHOLD = 512 * KB +INIT_BLOCKSIZE = 2048 * KB +MIN_BLOCKSIZE = 512 * KB +TIME_SLICE = 5 class Fetcher(asynchat.async_chat): def __init__(self, reader, endpoint, url, header, range): @@ -96,11 +97,10 @@ class MultipleProxyReader(object): self.endpoints_blocksize = [] for i in range(0,len(ENDPOINTS)): - self.endpoints_time.append(BLOCKSIZE_FETCH/(200*KB)) - self.endpoints_blocksize.append(BLOCKSIZE_FETCH) + self.endpoints_blocksize.append(INIT_BLOCKSIZE) for i in range(0,len(ENDPOINTS)): - self.start_fetcher(i,1) + self.start_fetcher(i,0) def handle_incoming_data(self, pos, data): self.blocks[pos] = data @@ -125,12 +125,10 @@ class MultipleProxyReader(object): def start_fetcher(self,endpoint,time): self.find_next_data() - - self.endpoints_time[endpoint] = time - if max(self.endpoints_time) == time: - self.endpoints_blocksize[endpoint] += BLOCKSIZE_STEP - elif min(self.endpoints_time) == time: - self.endpoints_blocksize[endpoint] -= BLOCKSIZE_STEP + + if time == 0: + speed = (self.endpoints_blocksize[endpoint] / time) + self.endpoints_blocksize[endpoint] = int(speed * TIME_SLICE) if self.fetch_pos +1