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

Re: [pygame] pygame networking redux



I'm not sure this is true or not, but it's something I think is the
case (untested)...


It seems that running twisted in a separate thread would be better for
keeping more consistent latency in networking.

If you wanted to run your networking at different frequencies to the
rest of your system.  It seems that some of the time, this would be
the case.  Much like sound requires updating at  different
frequencies.

Iterating it at eg. 72fps means that the quickest data can go out is
at 1/72 messages per second?

If you don't have a consistent frame rate, say a frame too 1/14th of a
second because of some heavy graphics - then messages would only come
out every 1/14th of a second.

Whereas if you ran twisted in another thread it would be separate of
those concerns - and could run at a different frequency.  Maybe a
lower frequency even.

As a bonus all your networking stuff can be handled by a separate
CPU/Core if available.


Or am I way off here?  Maybe it doesn't matter.



On 6/6/07, Simon Wittber <simonwittber@xxxxxxxxx> wrote:
Richard Jones just mentioned to me off list how he is using twisted.
(He is having issues with the mailing list).

Using twisted like this is not intrusive, as it lets me keep control
of the main loop. Thanks Richard!



    We've just run into this ourselves, but in our case integrating Twisted
    into a pyglet application (though not into its event system yet - just
    into the main loop).

    The docs are extremely sparse in this area, but the following is mostly
    working for us:

      reactor.startRunning(1)       (or 0 if you don't want it to take
over signals)
      while main_loop:
         reactor.iterate(0.01)

    then when you want to exit your program, use:

       reactor.stop(); reactor.iterate(0.01)