From: Cameron Dale Date: Wed, 23 Apr 2008 02:10:21 +0000 (-0700) Subject: Disconnect the insertNode calls from the callers so errors don't affect them. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=593a583cc5076643890a811d2fb1a5e0548f290c;p=quix0rs-apt-p2p.git Disconnect the insertNode calls from the callers so errors don't affect them. --- diff --git a/apt_p2p_Khashmir/actions.py b/apt_p2p_Khashmir/actions.py index 0ac9647..bd1cd2f 100644 --- a/apt_p2p_Khashmir/actions.py +++ b/apt_p2p_Khashmir/actions.py @@ -186,7 +186,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 diff --git a/apt_p2p_Khashmir/khashmir.py b/apt_p2p_Khashmir/khashmir.py index 15237a2..5db5ed8 100644 --- a/apt_p2p_Khashmir/khashmir.py +++ b/apt_p2p_Khashmir/khashmir.py @@ -233,7 +233,7 @@ class KhashmirBase(protocol.Factory): """Node responded properly, callback with response.""" n = self.Node(dict['id'], dict['_krpc_sender'][0], dict['_krpc_sender'][1]) self.stats.completedAction('join', start) - self.insertNode(n) + reactor.callLater(0, self.insertNode, n) if callback: callback((dict['ip_addr'], dict['port'])) @@ -306,7 +306,7 @@ class KhashmirBase(protocol.Factory): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) return {"id" : self.node.id} @@ -320,7 +320,7 @@ class KhashmirBase(protocol.Factory): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) else: _krpc_sender = ('127.0.0.1', self.port) @@ -338,7 +338,7 @@ class KhashmirBase(protocol.Factory): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) else: _krpc_sender = ('127.0.0.1', self.port) @@ -414,7 +414,7 @@ class KhashmirRead(KhashmirBase): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) nodes = self.table.findNodes(key) nodes = map(lambda node: node.contactInfo(), nodes) @@ -436,7 +436,7 @@ class KhashmirRead(KhashmirBase): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) l = self.store.retrieveValues(key) if num == 0 or num >= len(l): @@ -496,7 +496,7 @@ class KhashmirWrite(KhashmirRead): """ if _krpc_sender is not None: n = self.Node(id, _krpc_sender[0], _krpc_sender[1]) - self.insertNode(n, contacted = False) + reactor.callLater(0, self.insertNode, n, False) else: _krpc_sender = ('127.0.0.1', self.port)