Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
Unlike unix-variants, in Windows, the multiprocessing module has to launch a new copy of the intepreter - there is no "fork" function.
In the case of Poser Python, the interpreter is Poser. You can't launch a new copy of Poser - Poser prevents two copies on purpose.
However, if you are not using Poser Python in your script, but rather just pure ordinary Python, (i.e. you're not using internal objects published by the Poser engine) you have the option to spawn a subprocess (not multiprocess) of an ordinary Python interpreter, and then let that multiprocess if it wants to.
If you're trying to do some difficult calculation (perhaps involving geometry) it may be better to export the geometry to a collection of pure-python subprocesses.
Side note: I have been experimenting with boost-python - an easy way to connect a pure C++ class library to Python and make it possible to call all the C++ methods without you having to write any glue code. This makes for some damn fast add-on modules for Python.
http://www.boost.org/doc/libs/1_53_0/libs/python/doc/index.html
When you call into C++, the global interpreter lock (GIL) is released so real multi-threading can happen. If you're doing the hard work in C++, you may not even need multiple CPU cores, but if you want them, they're a lot easier to deal with in C++. Well, easier being a relative term. A bunch of other stuff is harder. Depends on the problem. For me, it's cryptography and it's easier in C++ because all the crypto functions are in C.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)
Hi Bill, thanks a lot. How is it decided whether it is a pure python subprocess? When I was using Process.start(), this seems to have a created a new poserpython process. You are right that C++ is easier for the things that need speed. The calculations I need are rather easy to write down in c++ too. But then there is the 32/64 win/mac problem again. Or can the boost solve this? I want to support both win and mac for my script. The c++ speedup could make my script a much better experience. its slow currently.
Quote - How is it decided whether it is a pure python subprocess?
What I mean is, are you doing "import poser", or calling methods of Poser objects, such as actor methods? If so, this is Poser python and cannot be executed in the pure python (python.exe) interpreter - such objects do not exist in pure Python. In such case, you can only do your work while being interpreted inside Poser. This would mean single process for your Python code.
Quote - But then there is the 32/64 win/mac problem again. Or can the boost solve this?
boost::python is cross platform - win/mac/linux - it's great. Of course the build steps are different, but the source code is identical. You write the C++ once and any difference in OS can be hidden in boost for C++. For example, if you're dealing with pipes or files or sockets, etc. You also do not care about 32/64 - that is just a matter of compiler flags. Everything is taken care of for you.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)
Hm, I think I did not even do import poser. poser is I think always visible. I tried with python shell: import multiprocessing def foo(something): return p = Process(target = foo, args = (0,) ) p.start() poser will then suddenly try to open a new scene in a script poser deadlocked. i had the if main in place.
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
did anyone manage to get multiprocessing run properly? i feel whenever I want to start a subprocess, poser wants to create a new scene maybe that module is just not usable in poser?