Fri, Jan 3, 9:46 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Multiprocessing possible?


colorcurvature ( ) posted Sun, 24 March 2013 at 9:21 AM · edited Wed, 01 January 2025 at 7:19 AM

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?


bagginsbill ( ) posted Sun, 24 March 2013 at 10:54 PM · edited Sun, 24 March 2013 at 10:59 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)


colorcurvature ( ) posted Mon, 25 March 2013 at 1:39 AM

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.


bagginsbill ( ) posted Mon, 25 March 2013 at 4:43 PM

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)


colorcurvature ( ) posted Tue, 26 March 2013 at 1:01 AM · edited Tue, 26 March 2013 at 1:02 AM

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.


andygraph ( ) posted Sat, 06 April 2013 at 10:16 AM

I want poser work with GPU too !!! Smithmicrooooo ...... are you there ?


ironsoul ( ) posted Mon, 08 April 2013 at 4:10 PM

Does the python interpretor used by Poser support threads? The threadclass shown on the IBM website looks quite neat.



Privacy Notice

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.