[Twisted-Python] sleeping in inlineCallbacks

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Oct 29 21:07:38 MDT 2009


On 01:26 am, mithrandi at mithrandi.net wrote:
>On Thu, Oct 29, 2009 at 8:38 PM, Brian Granger 
><ellisonbg.net at gmail.com> wrote:
>>One question though - can someone explain the need/usage cases for
>>task.Clock and the other things in task?
>
>Clock is a "fake" IReactorTime implementation; as the docstring says,
>it is intended for writing unit tests where you want control over the
>behaviour of the clock, rather than using the real time source.
>
>As for the other things... LoopingCall repeatedly runs a callable at a
>certain interval, coiterate takes a generator and iterates it
>cooperatively (returning control back to the reactor between
>iterations), and cooperate is a new-and-improved version of coiterate
>which I haven't looked at yet.

cooperate and coiterate basically do the same thing.  The difference is 
that cooperate gives you access to extra features, like pausing, 
resuming, and canceling.

Jean-Paul




More information about the Twisted-Python mailing list