]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Fix a bug in the ThrottlingProtocol when writeSequence is called with a tuple.
authorCameron Dale <camrdale@gmail.com>
Fri, 11 Apr 2008 06:34:40 +0000 (23:34 -0700)
committerCameron Dale <camrdale@gmail.com>
Fri, 11 Apr 2008 06:34:40 +0000 (23:34 -0700)
apt_p2p/policies.py

index e7bae81cbcf236741c58d8e977a6d469a4882536..9dc7ec80da5774c5a6e5f386f72da1b7829f16ee 100644 (file)
@@ -146,15 +146,17 @@ class ThrottlingProtocol(ProtocolWrapper):
             self._throttleWrites()
 
     def writeSequence(self, seq):
+        i = 0
         if not self.throttled:
             # Write each sequence separately
-            while seq and not self.factory.registerWritten(len(seq[0])):
-                ProtocolWrapper.write(self, seq.pop(0))
+            while i < len(seq) and not self.factory.registerWritten(len(seq[i])):
+                ProtocolWrapper.write(self, seq[i])
+                i += 1
 
         # If there's some left, we must have been paused
-        if seq:
-            self._tempDataBuffer.extend(seq)
-            self._tempDataLength += reduce(operator.add, map(len, seq))
+        if i < len(seq):
+            self._tempDataBuffer.extend(seq[i:])
+            self._tempDataLength += reduce(operator.add, map(len, seq[i:]))
             self._throttleWrites()
 
     def dataReceived(self, data):