[Twisted-Python] Two main loops

Nitro nitro at dr-code.org
Sun Nov 11 11:16:58 EST 2007


Am 11.11.2007, 16:44 Uhr, schrieb Jean-Paul Calderone <exarkun at divmod.com>:

> On Sun, 11 Nov 2007 09:51:33 -0500, Bernie Roehl <broehl at gmail.com>  
> wrote:
>> Did you find that passing zero as the first parameter to callLater
>> cause it to be called often enough?  I really want to make sure the
>> rendering is happening as quickly as possible.
>>
>
>     exarkun at boson:~$ cat howfastdoesitspin.py
>
>     from twisted.internet import reactor
>     from twisted.internet.task import LoopingCall
>
>     class Spinner(object):
>         def __init__(self):
>             self.count = 0
>
>         def tick(self):
>             self.count += 1
>
>     spinner = Spinner()
>     call = LoopingCall(spinner.tick)
>     call.start(0)
>     reactor.callLater(1, reactor.stop)
>     reactor.run()
>     print spinner.count
>     exarkun at boson:~$ python howfastdoesitspin.py
>     5448
>     exarkun at boson:~$
>
> Practically speaking, you probably don't need to render more than about
> 3000 frames per second.  ;)

HarHar, I get about 13000 on my win machine ;-)

-Matthias




More information about the Twisted-Python mailing list