I don't understand why this approach wouldn't work in general. The python
multiprocessing module explicitly uses subprocess, not threads. Separate
processes (even if spawned by each other) should each be able to handle
their own OpenGL contexts.
Perhaps the problem is that multiprocessing is forking the current process,
which probably means that you need to make sure all OpenGL-related stuff is
started _after_ the separate process is running. Why don't you try
something like this and see how it goes?
import multiprocessing
def inprocess():
import pyglet
b = pyglet.graphics.Batch()
w = pyglet.window.Window()
pyglet.app.run()
p = multiprocessing.Process(target=inprocess)
p.start()
p.join()
~ Nathan
On Mon, Nov 5, 2012 at 1:25 PM, Tristam MacDonald <[email protected]>wrote:
> It's a general limitation of OpenGL, that calls to OpenGL can only occur
> from a single thread. There is no easy way to work around that limitation,
> pre OpenGL version 4+.
>
>
> On Mon, Nov 5, 2012 at 3:21 PM, Gabriele Lanaro <[email protected]
> > wrote:
>
>> I've tried several approaches to run pyglet in parallel with the
>> executing code. One (partially) successful solution was to simply run
>> pyglet-related stuff into a mutliprocessing.Process and communicating using
>> a sync primitive such as a Queue. The problem I'm having is that this
>> approach doesn't play nicely with all the drivers, a test code like the
>> following, works nicely on 'radeon' open source drivers, but it doesn't
>> work on proprietary nvidia drivers (the subprocess sort-of crashes at line
>> 6). If I remove the call to Batch (or any other opengl-related call) it
>> works with both video cards/drivers. Do you think there's an explanation
>> for this? I'd prefer avoiding to restrict all references to opengl in just
>> one process the reason is that I basically cache shaders in the main
>> process. I was wondering if there exist some way to prevent this kind of
>> problems.
>> --------------------------
>> import pyglet
>> import multiprocessing
>> b = pyglet.graphics.Batch()
>>
>> def inprocess():
>> w = pyglet.window.Window()
>> pyglet.app.run()
>>
>> p = multiprocessing.Process(target=inprocess)
>> p.start()
>> p.join()
>> ---------------------------
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pyglet-users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/pyglet-users/-/SOjRn2XTbF8J.
>> 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/pyglet-users?hl=en.
>>
>
>
>
> --
> Tristam MacDonald
> Software Development Engineer, Amazon.com
> http://swiftcoder.wordpress.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" 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/pyglet-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" 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/pyglet-users?hl=en.