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

Re: [pygame] Thread issue in my graphics API (pygame)



Hello,

Only the primary thread (the first one to import the pygame module)
should do X stuff (ie pygame events, flipping the screen and drawing
stuff to the screen). This is very important as it will appear to work
most of the time but randomly get the Xlib errors.

The same problem applies in MacOS X, I'm not sure about Windows. 

This isn't a problem only restricted to pygame, wxWidgets also suffers
from this problem.

Hope this helps.

Tim Ansell

On Thu, 2006-07-27 at 12:01 -0400, David Muffley wrote:
> Link to the mentioned file: http://dc.ubuntu-us.org/projects/gasp/
> 
> My system: ubuntu-dapper (2.6.1).  Line 325 is where the
> _event_handler is and I believe causes the issue.  I can recreate the
> bug quite easily by calling the 'begin_end()' method and letting it
> run until it breaks (2-7 seconds mostly).  I cannot even confirm that
> this will run on Windows or Mac OS X. 
> 
> I am having a problem with using a thread in my program (attached).  I
> have an event handler which I have run in a separate thread, which
> redraws the screen (linux) and quits if the 'x' is pressed.  However,
> I seem to be running into a threading problem with this set-up.  When
> I attempt to close the graphics window, I will occasionally (about
> 20-30% of the time) recieve an error message: 
> 
>     "Xlib: unexpected async reply (sequence 0x##)!" (where ## are two
> numbers)
> 
> I googled it and found that it's a threading issue, but not much more,
> such as WHAT is actually wrong or ways to avoid the error.  I'm
> looking for anyone out there that can help me solve this issue, your
> help would be much appreciated. 
> 
>  ----