Commits

Matt Joiner  committed a4681f6

Fix epic bug in Torrent.generate_requests

  • Participants
  • Parent commits ecd8744
  • Tags stable

Comments (0)

Files changed (1)

File lib/torrent.py

     def top_up_requests(self, conn):
         request_generator = self.generate_requests(conn)
         try:
+        #~ with self.generate_requests(conn) as request_generator:
             while not conn.am_choked and len(conn.our_requests) < conn.peer_reqq:
                 try:
                     request = request_generator.__next__()
     def generate_requests(self, conn):
         with self.active_peers_lock:
             all_requests = set()
-            for conn in self.active_peers:
-                all_requests.update(conn.our_requests)
-        for index in self.wanted_blocks.keys() & conn.peer_bitfield:
+            for conn1 in self.active_peers:
+                all_requests.update(conn1.our_requests)
+        for index in self.wanted_pieces() & conn.peer_bitfield:
             choices = {(index,) + block for block in self.wanted_blocks.get(index, ())}
             choices -= conn.our_requests
             choices -= all_requests