[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Networking?
On Thu, 22 Nov 2007, David wrote:
> On 11/20/07, Richard Jones <richardjones@xxxxxxxxxxxxxxxx> wrote:
> > > 2) Use the Twisted reactor *as* your main loop, and implement all game
> > > logic as call-backs from there. This is the approach that the Twisted
> > > people will recommend.
> >
> > This is also useless for highly interactive games.
>
> I consider my game highly interactive, though the network traffic intensity
> is not very high. Can you elaborate
> on why the Twisted reactor is useless?
The minimum time you can pass to iterate() is quite high -- 0.01 seconds IIRC.
This means a significant amount of processing time is lost.
A possible solution is to only run the reactor.iterate() once every few
frames.
> > 3) Run the Twisted reactor in its own thread
> >
> > This is probably the only reasonable approach for games.
>
> My only experience with threads was in writing an image slideshow program.
> The graphic blends
> and transitions were very jerky with threads. Changing to a
> generator-coroutine approach worked more
> smoothly. I do not recall any capability in the thread modules for
> adjusting 'niceness' or state-change frequency.
True - this is a problem I ran into. The only solution I could find was to
have the thread periodically artificially block using a semaphore.
Richard