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

Re: [pygame] pygame networking redux



That's essentially the same thing... When you set your delay low enough, your code will be run once every time through twisted's loop -- which is effectively the same as twisted's loop being run once every time through your loop. "Ownership" of the loop makes little difference, and is easy to change should it actually turn out to matter.

Also, although It's been some years since I've actually tried it (so I don't remember the details), I vaguely recall having some trouble with code analogous to the below code, and also vaguely recall that it was actually slower for me. It's pretty simple to switch though, so probably worth trying it both ways.

Hearing that the guy suggesting this approach has it only "mostly working" isn't exactly encouraging though.

-Jasper

Simon Wittber 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)