On Mon, Nov 29, 2010 at 2:08 PM, Paul Solt <[email protected]> wrote:

> Claudio,

My problem is only related to long calculations on the same thread as
> Pyglet, not garbage collection. The calculations are out of my
> control, since it is user created AI game logic. The game is a non-
> trivial graph problem, which cannot be solved in real-time and the
> solution space is too large for computer memory. You can see an
> example of a similar game here: http://paulsolt.com/projects/labyrinth/
>
>


I agree that using threads seems the way to go.
While not specif to pyglet, the article
http://wiki.wxpython.org/LongRunningTasks can give you an idea about how to
organize the code.
Remember that the main thread must be the gui thread.

I can't give you a pyglet threaded example, but if you try to build one I
volunteer to help with problems that can arise.
Fair warning: I'm not experienced with threads.

You say '..the calculations are out of my control'
You have enough control to modify or wrap in a way that thread
synchronization can be done ?


> Animation stuttering may not be the correct description. The blocking

calculation causes animation frames to be skipped in the beginning of
> an animation sequence. This means that users do not see the full
> animations if the time delta in the _step function is very large. My
> current workaround is to skip updates if the time delta is above a
> certain threshold.
>
>
Yes, this will solve the 'skipped begin animation' problem.
I won't solve the problem that animations running when the calc begin will
be frozen for the duration of calc; threads will help with that also.

It may be worth to ask also in pyglet mailing list 'how to use threads to
avoid long calculation block pyglet main loop'.
You can easily modify the pyglet example noisy.py to demostrate the
problem.

--
claudio

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to