[Twisted-Python] Twisted-Python Digest, Vol 63, Issue 7
Doug Farrell
dfarrell at mypublisher.com
Mon Jun 8 10:46:03 EDT 2009
Terry
> Hi Doug
>
> Sorry if it sounds like I'm being a PITA, but I really recommend
> reading
> the source code and writing & playing with a tiny example. Also see
>
http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.task.Loop
> ingCall.html
>
> I suggest this because it's by far the best way to learn these things.
> And
> if you're using Twisted in any serious way, it's hard to get by
without
> getting closely acquainted with some of the code.
>
> BTW, yes, LoopingCall will reschedule in a sensible way, supposing
your
> task returns a deferred that takes a long time to fire :-) Try it.
>
> Terry
>
[Doug Farrell] Don't mind the PITA at all, I actuall did read the source
code and just didn't 'get it' so much. In my case the function that
LoopingCall was passed was actually doing the work, not returning a
Deferred. However, I'm going to look into doing that.
Thanks for your feedback and advice,
Doug
> per
>
http://twistedmatrix.com/documents/current/api/twisted.internet.task.Lo
> opingCall.html
>
> If someFunction returns a Deferred, it will not be rescheduled if the
> Deferred has not fired.
>
> e.g.
>
> def someFunction():
> d = someDeferredReturningOperation()
> d.addCallbacks(success, error)
> return d
>
> lp = LoopingCall(someFunction)
> lp.start(5.0) # run every 5 seconds
>
>
> Lucas
>
[Doug Farrell]
Lucas,
Thanks for your response and feedback. In my sample code the
someFunction() code was actually doing the work I wanted, not creating a
deferred as your sample shows. However, I'm going to try that out and
give it a run.
Thanks!
Doug
More information about the Twisted-Python
mailing list