[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame networking redux



Simon Wittber wrote:
Ah I can see how you solved the problem:

def main(self):
        self.checkEvents(pygame.event.get())

        ... snip lots of code ...

        #come back here at a rate of approx 30fps
        reactor.callLater(0.03, self.main)

Basically you asked twisted to call your function, and when your
function finishes, you ask twisted to call it again.

I'd prefer not to use twisted this way. It turns what should be a
simple, tight inner loop into a function call which has to work its
way through twisted's scheduling mechanics for every frame.

-Sw.



This is essentially what I do, yielding 60 frames/second of 3D and animation without any trouble. I don't think the twisted overhead is as big as you fear, and it's definitely several orders of magnitude nicer than dealing with low level networking protocols. It has been easily fast enough, Perspective Broker saved me from (re)writing tons of code, and I've undoubtedly avoided plenty of nasty networking bugs as well.

What would you hope to gain by rolling your own networking code?

-Jasper