[Twisted-Python] how manual run LoopingCall.f

Glyph Lefkowitz glyph at twistedmatrix.com
Fri Jan 1 05:10:25 EST 2010


On Dec 28, 2009, at 8:05 AM, ploutosss ploutosss wrote:

> When I need to perform some function with a time interval of less than
> one second, LoopingCall too slow.

LoopingCall was originally designed for playback of voice samples, in an application which did that once every 10ms, or 0.01 seconds.  It should really be fast enough for you: if it is really too slow, I am guessing that something else is wrong.

> I try use my ticking, but for
> function is not executed too often, I used the following code:
> 
>    def some_function(self):
>        looping_instance = self.looping
>        call = looping_instance.call
>        if call and call.time - call.seconds() <= 0:
>            looping_instance()

This example isn't complete, so I am not sure what the problem is, but I can guess that 'looping_instance' is a LoopingCall instance.  You should not be calling it using __call__ (really, this method is just a cute hack so that the LoopingCall instance can be passed directly to callLater, and show up in the DelayedCall repr, among other things), you should be using its "start" method.

Good luck!


More information about the Twisted-Python mailing list