[Twisted-Python] reactor.callLater always requires args object?

orbitz orbitz at ezabel.com
Wed Jul 21 12:45:44 MDT 2004


You give callback the result to pass to the first callback in the 
deferred, why are you using a deferred for this? why not just 
reactor.callLater(3, checkForSanity) ?


Sergio Trejo wrote:

> I'm trying to be a good soldier by heeding the warning issued by the 
> Twisted gods warning strongly *not* to use defer.Deferred's 
> setTimeout() and instead using  reactor.callLater
>
> I've looked at the API for twisted.internet.defer.Deferred.callback 
> and twisted.internet.default.SelectReactor.callLater (which refers one 
> to see twisted.internet.interfaces.IReactorTime.callLater which I have 
> also read). I don't understand why at least one args object must 
> always be supplied to reactor.callLater, as in:
>
> reactor.callLater(3, d.callback, "an unused arg")
>
> even though the callback function:
>
> d.addCallback(checkForSanity)
>
> receives no args:
>
> def checkForSanity():
>     print "this is a sanity test"
>
> In order to get the reactor.callLater to perform the callback, I had 
> to pass in at least one arg:
>
> def checkForSanity(ignoreMe):
>     print "this is a sanity test"
> d = defer.Deferred()
> d.addCallback(checkForSanity)
> reactor.callLater(3, d.callback, "ignore me")
>
> There's sure to be a good reason why, perhaps something utterly 
> obvious to most but as a newbie I'm still trying to grok as much as 
> possible where needed. Thanks for any clarification.
>
> Serg
>
> _________________________________________________________________
> MSN 8 with e-mail virus protection service: 2 months FREE* 
> http://join.msn.com/?page=features/virus
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>





More information about the Twisted-Python mailing list