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

Re: [pygame] Problem clock.tick() and Threads



On Mon, 2005-10-24 at 11:45 +0200, Juju Cece wrote:
> On my main Loop I use:
> clock.tick(100)
> To limit the FPS (but I update the Frame 1 time on 2)

Before calling clock.tick(), you could add a pygame.time.wait(0). This
will keep the other python threads running. This is probably going to be
the best way to get what you want.

The wait() function also returns the the time spent in the actual call.
You could measure this return value over time to see how much time the
background threads are taking from the primary thread.

Because of the way the python threads work, threads for the networking
may not be the best approach. Without any extra dependencies you could
use the "select" module to grab and push data over the network in
smaller pieces that do not stop the main thread.