[Twisted-Python] Problems with deferred
Andrew Bennetts
andrew-twisted at puzzling.org
Mon Jul 7 19:54:22 MDT 2003
On Tue, Jul 08, 2003 at 12:30:43AM +0200, Thomas Weholt wrote:
>
> def execute(self):
> d = defer.Deferred()
> reactor.callLater(0, self.action)
>
> # Log any errors in downloading or processing
> d.addErrback(log.err)
>
> # Reschedule this function
> d.addBoth(reactor.callLater, self.refreshInterval, self.execute)
This function is obviously wrong. It creates a Deferred, but there is no
reference to it outside of this function. So there is nowhere else in your
code that could get an opportunity to call d.callback or d.errback, and this
function never calls that, thus this Deferred will never fire. So this
function is equivalent to:
def execute(self):
reactor.callLater(0, action)
I'm guessing this isn't what you meant :)
I think you've possibly confused reactor.callLater with
twisted.internet.threads.deferToThread?
-Andrew.
More information about the Twisted-Python
mailing list