threaded pyglet

203 views
Skip to first unread message

Janto

unread,
Jan 3, 2008, 4:19:30 AM1/3/08
to pyglet-users
Hi!

I'm getting "Xlib: unexpected async reply" errors in my pyglet
application. This is apparently due to my multithreaded calls to
pyglet (see http://www.faqs.org/faqs/x-faq/part7/section-15.html).

Is it possible to use pyglet and threads together?

Thanks!
Janto

Alex Holkner

unread,
Jan 3, 2008, 5:37:45 AM1/3/08
to pyglet...@googlegroups.com

pyglet is completely thread-unsafe; you'll need to manage all locking yourself.

Alex.

Rod Hyde

unread,
Jan 3, 2008, 6:25:22 AM1/3/08
to pyglet...@googlegroups.com
On Jan 3, 2008 9:19 AM, Janto <jan...@gmail.com> wrote:

> Is it possible to use pyglet and threads together?

Yes, as long as you confine of your Pyglet-related calls to a single thread.

--- Rod

Richard Jones

unread,
Jan 3, 2008, 3:52:14 PM1/3/08
to pyglet...@googlegroups.com

I have, but as with all threaded applications you're opening a can of worms.

Ensure only one thread is doing actual pyglet stuff (rendering, event loop,
etc). See how you go...


Richard

Janto

unread,
Jan 4, 2008, 3:26:51 AM1/4/08
to pyglet-users
Thanks Alex, Rod and Richard! Looks like I'm going to have to write an
events queue and listener.

On Jan 3, 10:52 pm, Richard Jones <r1chardj0...@gmail.com> wrote:
> On Thu, 3 Jan 2008, Janto wrote:
> > I'm getting "Xlib: unexpected async reply" errors in my pyglet
> > application. This is apparently due to my multithreaded calls to
> > pyglet (seehttp://www.faqs.org/faqs/x-faq/part7/section-15.html).

Ben Sizer

unread,
Jan 4, 2008, 7:33:53 AM1/4/08
to pyglet-users
On Jan 3, 8:52 pm, Richard Jones <r1chardj0...@gmail.com> wrote:
> Ensure only one thread is doing actual pyglet stuff (rendering, event loop,
> etc). See how you go...

In particular, it's common for rendering systems to require all access
to be done from just one thread (sometimes only the main thread). For
a library to attempt to remove that restriction for you would probably
impose all sorts of locking overhead behind the scenes for very little
gain.

--
Ben Sizer

John Lehmann

unread,
Jan 13, 2008, 9:10:41 AM1/13/08
to pyglet...@googlegroups.com
Depending completely on what you are doing with threads, you could have a look at something like greenlets - http://codespeak.net/py/dist/greenlet.html - or if you were doing networking - http://wiki.secondlife.com/wiki/Eventlet

John
Reply all
Reply to author
Forward
0 new messages