From: Brian Warner Date: Sun, 3 Dec 2006 07:53:07 +0000 (-0700) Subject: client: closures confuse me, late binding bites me yet again X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~484 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/file/URI:LIT:krugkidfnzsc4/about.html?a=commitdiff_plain;h=9a555e6710af61d9cce0c0b84561a35ba23cf7d2;p=tahoe-lafs%2Ftahoe-lafs.git client: closures confuse me, late binding bites me yet again --- diff --git a/allmydata/client.py b/allmydata/client.py index bc004789..a8608722 100644 --- a/allmydata/client.py +++ b/allmydata/client.py @@ -82,11 +82,13 @@ class Client(node.Node, Referenceable): self.all_peers.add(nodeid) if nodeid not in self.connections: d = self.tub.getReference(pburl) - def _got_reference(ref): - self.log("connected to %s" % idlib.b2a(nodeid)) - if nodeid in self.all_peers: - self.connections[nodeid] = ref - d.addCallback(_got_reference) + def _got_reference(ref, which_nodeid): + self.log("connected to %s" % idlib.b2a(which_nodeid)) + if which_nodeid in self.all_peers: + self.connections[which_nodeid] = ref + else: + log.msg(" ignoring it because we no longer want to talk to them") + d.addCallback(_got_reference, nodeid) def remote_lost_peers(self, lost_peers): for nodeid in lost_peers: