From: Cameron Dale Date: Mon, 21 Apr 2008 18:54:05 +0000 (-0700) Subject: Fix an error in the actions that allowed for the result to be sent twice. X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=commitdiff_plain;h=aa0f99580b06354d1affbef134d5763b534026b6 Fix an error in the actions that allowed for the result to be sent twice. --- diff --git a/apt_p2p_Khashmir/actions.py b/apt_p2p_Khashmir/actions.py index 95aef72..fd5e1c1 100644 --- a/apt_p2p_Khashmir/actions.py +++ b/apt_p2p_Khashmir/actions.py @@ -117,6 +117,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 +127,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