diff options
author | Thomas Keck <thomas@macbook.macbook> | 2010-03-12 21:34:48 +0100 |
---|---|---|
committer | Thomas Keck <thomas@macbook.macbook> | 2010-03-12 21:34:48 +0100 |
commit | 6e36f1d7cdb60b2b4c71e70a5b3752f8c907f348 (patch) | |
tree | dfa548cbaec7ac32b725f17243d9b3e855f57874 | |
parent | d3c3ad16098a143cad8ac88b4d45a3179f9a7920 (diff) | |
download | magicproxy-6e36f1d7cdb60b2b4c71e70a5b3752f8c907f348.tar.gz magicproxy-6e36f1d7cdb60b2b4c71e70a5b3752f8c907f348.zip |
Fixed typos
-rw-r--r-- | proxy.py | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -22,7 +22,7 @@ BLOCKSIZE_STEP = 512 * KB class Fetcher(asynchat.async_chat): def __init__(self, reader, endpoint, url, header, range): self.reader = reader - self.proxy = ENDPOINTS(endpoint) + self.proxy = ENDPOINTS[endpoint] self.url = url self.header = header self.range = range @@ -56,7 +56,7 @@ class Fetcher(asynchat.async_chat): self.pos += len(data) if self.pos >= self.range[1]: self.stop_time = time.time() - self.start_fetcher(endpoint, self.time()) + self.reader.start_fetcher(self.endpoint, self.time()) print self, "finished" self.close_when_done() elif self.state ==1: #header @@ -92,9 +92,11 @@ class MultipleProxyReader(object): self.write_pos = 0 self.buffer = "" self.blocks = dict() + self.endpoints_time = [] + self.endpoints_blocksize = [] for i in range(0,len(ENDPOINTS)): - self.endpoints_time.append(1) + self.endpoints_time.append(BLOCKSIZE_FETCH/(200*KB)) self.endpoints_blocksize.append(BLOCKSIZE_FETCH) for i in range(0,len(ENDPOINTS)): @@ -125,20 +127,20 @@ class MultipleProxyReader(object): self.find_next_data() self.endpoints_time[endpoint] = time - if max(self.endpoints_times[endpoint]) == time: - self.endpoint_blocksize[endpoint] += BLOCKSIZE_STEP - elif min(self.endpoints_times[endpoint]) == time: - self.endpoint_blocksize[endpoint] -= BLOCKSIZE_STEP + 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 self.fetch_pos +1 <self.content_length: print self, "start new fetcher" start = self.fetch_pos - if self.fetch_pos+self.endpoint_blocksize[endpoint] < self.content_length: - self.fetch_pos += self.endpoint_blocksize[endpoint] + if self.fetch_pos+self.endpoints_blocksize[endpoint] < self.content_length: + self.fetch_pos += self.endpoints_blocksize[endpoint] else: self.fetch_pos = self.content_length range = (start, self.fetch_pos-1) - Fetcher(self, ENDPOINTS[endpoint], self.url, self.header, range) + Fetcher(self, endpoint, self.url, self.header, range) def find_next_data(self): if self.channel.is_closed: |