Is there a way to share PO-objects between more Processes? One Process does the rendering,
the other the input or so. I tried to spawn a process in python using the multiprocessing package
and give it the ogre.root as parameter, but there comes an error wich says "pickling is disabled for .....)
-> he cannot serialize the object. Is there a way of shared memory in python? i just want to acces PO
objects from a few processes.
Isn't Ogre::root a singleton anyway ? So you should be able to do something like:
root = ogre.Root.getSingleton()
Thats working with threads, but not with processes. every process
has his own memory, so this does not work... i want to use multiprocessing
not multithreading, because multithreading in python isn't real multithreading
because of the GIL.
You'd probably have to use something like Ampoule
to send messages between the processes. The one process running Ogre would just receive the messages and relay them to Ogre.
I already did it with pyro - python remote objects. Its like RMI in java,
very usefull. thanks for your help!
If you get a moment to write some demo code I'd be happy to add it to the svn as I think it would be of general interest...
Ok, first, download pyro and install it. i just tested it on windows.
if you are on linux, you can do multiprocessing with ogre, because
there is the POSH module (python object sharing) - not working in win32
Here is the code for pyro, just a quick example:
import ogre.renderer.OGRE as ogre
#This is a Pyro object, like 'extends Remote' in java
self.root = ogre.Root("plugins.cfg","ogre.cfg")
#init pyro and run the pyro listening server
#get the object proxy from the server
app_main = Pyro.core.getProxyForURI("PYROLOC://localhost:7766/app_main")
#you can call any funtions that are NOT returning ogre objects, because they are not serializable.
#maybe this can be enabled in the boost:python configuration, it's named pickling
#you can't do this:
Anyway, nobody thought about multiprocessing yet? I'm wondering because the threads in
python are **** because of the GIL =)
How do you implement multithreading, Andy?