[Twisted-Python] Two main loops

Jean-Paul Calderone exarkun at divmod.com
Sun Nov 11 08:44:21 MST 2007


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.  ;)

Jean-Paul




More information about the Twisted-Python mailing list