
July 31, 2003
1:13 p.m.
When I run the following code, everytime the callbacks to "onSuccess" get called, "item" is bound to the last element in "list". Obviously what I want is to have "item" bound to the value it had when I added the callback. How does one handle looping constructs like this in Twisted? def someFunc(): deferreds = [] def onSuccess(results): d = item.doSomethingElseThatReturnsDeferred() return d d = doSomethingThatReturnsDeferred() for item in list: d.addCallbacks(onSuccess, log.err) deferreds.append(d) return defer.DefferedList(deferreds)