[Twisted-Python] Passing extra arguments along callbacks
Terry Jones
terry at jon.es
Fri Oct 21 19:50:56 MDT 2011
Hi Jonathan
> def resolve(ip):
> ptr = '.'.join(ip.split('.')[::-1]) + '.in-addr.arpa'
> return client.lookupPointer(ptr).\
> addCallback(lambda x: (ip, x)).\
> addErrback(lambda x: (ip, x))
Your errback isn't raising and isn't returning a Failure, so the processing
switches back to the callback chain. If you add an errback that's a real
function and it raises something, things will work. E.g.
def err(fail, ip):
raise Exception(fail, ip)
return client.lookupPointer(ptr).\
addCallback(lambda x: (ip, x)).\
addErrback(err, ip)
> l = [resolve(ip) for ip in IPS]
> d = DeferredList( l, consumeErrors=True).\
> addCallback(display_results).\
> addCallback(lambda x: reactor.stop)
Try reactor.stop()
Terry
More information about the Twisted-Python
mailing list