From: Roland Haeder Date: Sat, 13 Jul 2013 13:25:54 +0000 (+0200) Subject: Fixed package loading (which let apt-p2p launch again) + used no more kept-alive... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c749275a35e84d45ea694f9dc90a89df09caf1b2;p=quix0rs-apt-p2p.git Fixed package loading (which let apt-p2p launch again) + used no more kept-alive connections as they caused some trouble (broken pipes). This is maybe caused by a (partly) broken HTTP implementation in Python (keep-alive seems to be broken). --- diff --git a/apt_p2p/AptPackages.py b/apt_p2p/AptPackages.py index f6f2e59..556db51 100644 --- a/apt_p2p/AptPackages.py +++ b/apt_p2p/AptPackages.py @@ -37,7 +37,7 @@ from twisted.python.filepath import FilePath from twisted.trial import unittest import apt_pkg, apt_inst -from apt.progress.base import OpProgress +from apt.progress.old import OpProgress from debian import deb822 from apt_p2p_conf import config diff --git a/apt_p2p/HTTPDownloader.py b/apt_p2p/HTTPDownloader.py index 8ecac19..243695a 100644 --- a/apt_p2p/HTTPDownloader.py +++ b/apt_p2p/HTTPDownloader.py @@ -231,7 +231,7 @@ class Peer(ClientFactory): req, deferRequest, submissionTime = self.request_queue.pop(0) try: - deferResponse = self.proto.submitRequest(req, False) + deferResponse = self.proto.submitRequest(req, True) except: # Try again later log.msg('Got an error trying to submit a new HTTP request %s' % (request.uri, )) diff --git a/apt_p2p_Khashmir/DHT.py b/apt_p2p_Khashmir/DHT.py index dbaf683..2b3c164 100644 --- a/apt_p2p_Khashmir/DHT.py +++ b/apt_p2p_Khashmir/DHT.py @@ -5,7 +5,7 @@ """ from datetime import datetime -import os, sha, random +import os, hashlib, random from twisted.internet import defer, reactor from twisted.internet.abstract import isIPAddress @@ -401,11 +401,11 @@ class TestSimpleDHT(unittest.TestCase): def store_values(self, result): self.stored = 3 - d = self.a.storeValue(sha.new('4045').digest(), str(4045*3)) + d = self.a.storeValue(hashlib.sha1('4045').digest(), str(4045*3)) d.addCallback(self.value_stored, 4045) - d = self.a.storeValue(sha.new('4044').digest(), str(4044*2)) + d = self.a.storeValue(hashlib.sha1('4044').digest(), str(4044*2)) d.addCallback(self.value_stored, 4044) - d = self.b.storeValue(sha.new('4045').digest(), str(4045*2)) + d = self.b.storeValue(hashlib.sha1('4045').digest(), str(4045*2)) d.addCallback(self.value_stored, 4045) def check_values(self, result, values): @@ -418,13 +418,13 @@ class TestSimpleDHT(unittest.TestCase): def get_values(self): self.checked = 4 - d = self.a.getValue(sha.new('4044').digest()) + d = self.a.getValue(hashlib.sha1('4044').digest()) d.addCallback(self.check_values, [str(4044*2)]) - d = self.b.getValue(sha.new('4044').digest()) + d = self.b.getValue(hashlib.sha1('4044').digest()) d.addCallback(self.check_values, [str(4044*2)]) - d = self.a.getValue(sha.new('4045').digest()) + d = self.a.getValue(hashlib.sha1('4045').digest()) d.addCallback(self.check_values, [str(4045*2), str(4045*3)]) - d = self.b.getValue(sha.new('4045').digest()) + d = self.b.getValue(hashlib.sha1('4045').digest()) d.addCallback(self.check_values, [str(4045*2), str(4045*3)]) def test_store(self): @@ -493,7 +493,7 @@ class TestMultiDHT(unittest.TestCase): if i == len(self.l): self.get_values() else: - d = self.l[j].storeValue(sha.new(str(self.startport+i)).digest(), str((self.startport+i)*(j+1))) + d = self.l[j].storeValue(hashlib.sha1(str(self.startport+i)).digest(), str((self.startport+i)*(j+1))) d.addCallback(self.store_values, i, j+1) def get_values(self, result = None, check = None, i = 0, j = 0): @@ -507,7 +507,7 @@ class TestMultiDHT(unittest.TestCase): if i == len(self.l): self.lastDefer.callback(1) else: - d = self.l[i].getValue(sha.new(str(self.startport+j)).digest()) + d = self.l[i].getValue(hashlib.sha1(str(self.startport+j)).digest()) check = [] for k in range(self.startport+j, (self.startport+j)*(j+1)+1, self.startport+j): check.append(str(k))