]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p_Khashmir/actions.py
Clean up the copyrights mentioned in the code.
[quix0rs-apt-p2p.git] / apt_p2p_Khashmir / actions.py
index 95aef72aaa9a1055fe1bc74664f50aa27ce589b6..fc8746cc86b2d572d5a49e11aed79a2266eeb1ff 100644 (file)
@@ -1,5 +1,3 @@
-## Copyright 2002-2004 Andrew Loewenstern, All Rights Reserved
-# see LICENSE.txt for license information
 
 """Details of how to perform actions on remote peers."""
 
@@ -117,6 +115,9 @@ class ActionBase:
     
     def schedule(self):
         """Schedule requests to be sent to remote nodes."""
+        if self.finished:
+            return
+        
         # Check if we are already done
         if self.desired_results and ((len(self.results) >= abs(self.desired_results)) or
                                      (self.desired_results < 0 and
@@ -124,9 +125,11 @@ class ActionBase:
             self.finished = True
             result = self.generateResult()
             reactor.callLater(0, self.callback, *result)
+            return
 
-        if self.finished or (self.desired_results and 
-                             len(self.results) + self.outstanding_results >= abs(self.desired_results)):
+        # Check if we have enough outstanding results coming
+        if (self.desired_results and 
+            len(self.results) + self.outstanding_results >= abs(self.desired_results)):
             return
         
         # Loop for each node that should be processed
@@ -181,7 +184,7 @@ class ActionBase:
 
     def gotResponse(self, dict, node, expected_results, df):
         """Receive a response from a remote node."""
-        self.caller.insertNode(node)
+        reactor.callLater(0, self.caller.insertNode, node)
         if self.finished or self.answered.has_key(node.id):
             # a day late and a dollar short
             return
@@ -193,8 +196,7 @@ class ActionBase:
 
     def actionFailed(self, err, node, expected_results, df):
         """Receive an error from a remote node."""
-        log.msg("action %s failed (%s) %s/%s" % (self.action, self.config['PORT'], node.host, node.port))
-        log.err(err)
+        log.msg("action %s failed on %s/%s: %s" % (self.action, node.host, node.port, err.getErrorMessage()))
         self.caller.table.nodeFailed(node)
         self.outstanding -= 1
         self.outstanding_results -= expected_results