Prev | Index | Next

Triggering a Deferred

from twisted.internet import defer, reactor

def getResult():
    d = defer.Deferred()
    # instead of waiting for "real" result we
    # just schedule result for later
    reactor.callLater(1, d.callback, 2)
    return d

def getResult2():
    d = defer.Deferred()
    d.callback(1)
    return d