[Twisted-Python] deferredGenerator ad errbacks

Manlio Perillo manlio_perillo at libero.it
Sat Apr 15 06:02:21 EDT 2006

Hi again!

I have started to use deferredGenerator:

from twisted.internet import defer, reactor

def waitFor(seconds):
    """It would be nice to have this in twisted.internet.defer.
       Thanks to Matt Goodall.

    d = defer.Deferred()
    reactor.callLater(seconds, lambda: d.callback(None))

    return defer.waitForDeferred(d)

def generator():
    d = defer.waitForDeferred(defer.succeed(1))
    yield d

    d = defer.waitForDeferred(defer.fail(Exception("error 1")))
    yield d

#    raise Exception("error 2")

    yield waitFor(3)

    d = defer.waitForDeferred(defer.succeed(2))
    yield d

def callback(result=None):
    print result

def errback(reason):
    print reason

g = generator()
g.addCallbacks(callback, errback)

The "problem" is that my errback is never called.
Is this a limitation of the deferred Generators?

Thanks   Manlio Perillo

More information about the Twisted-Python mailing list