From 593a583cc5076643890a811d2fb1a5e0548f290c Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Tue, 22 Apr 2008 19:10:21 -0700 Subject: [PATCH] Disconnect the insertNode calls from the callers so errors don't affect them. --- apt_p2p_Khashmir/actions.py | 2 +- apt_p2p_Khashmir/khashmir.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) 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) -- 2.39.5