[Twisted-Python] Two main loops

Jean-Paul Calderone exarkun at divmod.com
Sun Nov 11 10:44:21 EST 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)
    reactor.callLater(1, reactor.stop)
    print spinner.count
    exarkun at boson:~$ python howfastdoesitspin.py
    exarkun at boson:~$

Practically speaking, you probably don't need to render more than about
3000 frames per second.  ;)


More information about the Twisted-Python mailing list