]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
encode: fix multi-segment uploads: lambdas inside for loops require special attention...
authorBrian Warner <warner@allmydata.com>
Wed, 18 Apr 2007 03:29:08 +0000 (20:29 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 18 Apr 2007 03:29:08 +0000 (20:29 -0700)
src/allmydata/encode.py

index 5b74f107a2c14acf1b8d7a54bec1ee27ba641349..3731999da026f8b968712e11cc61a90dd7296600 100644 (file)
@@ -151,7 +151,11 @@ class Encoder(object):
         d = defer.succeed(None)
 
         for i in range(self.num_segments-1):
-            d.addCallback(lambda res: self.do_segment(i))
+            # note to self: this form doesn't work, because lambda only
+            # captures the slot, not the value
+            #d.addCallback(lambda res: self.do_segment(i))
+            # use this form instead:
+            d.addCallback(lambda res, i=i: self.do_segment(i))
         d.addCallback(lambda res: self.do_tail_segment(self.num_segments-1))
 
         d.addCallback(lambda res: self.send_all_subshare_hash_trees())