[Twisted-Python] Two main loops
Jasper
jasper at peak.org
Sun Nov 11 16:06:26 EST 2007
Jean-Paul Calderone wrote:
> 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
That depends. When I send moderately sized objects over Twisted, this
approach causes my frame rate to stop while Twisted is busy, and worse
makes my GUI non-interactive. For a game, this is generally unacceptable...
I'm not sure of a good/nice way to deal with this. Slicing
transmissions into a sequence of smaller chunks seems like a fair pain
in the ass, but then again the alternatives are punting to another
thread/process. :-/
-Jasper
More information about the Twisted-Python
mailing list