So, I'm writing this script to export particles from SI in Python, and its performing well using that ProjectItem.EvaluateAt() method to export the animation.
But, my tests where with < 1000 particles. Is there a way to multithread a python script so I can spread the work out across processors?
-TS-
Multithreaded Python
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: Multithreaded Python
Well, if you end up with a multithreaded plugin, you should not be calling the Softimage SDK from your worker threads. The SDK isn't multithreaded.TwinSnakes007 wrote:So, I'm writing this script to export particles from SI in Python, and its performing well using that ProjectItem.EvaluateAt() method to export the animation.
But, my tests where with < 1000 particles. Is there a way to multithread a python script so I can spread the work out across processors?
-TS-
-
luceric
- Posts: 1252
- Joined: 21 Jun 2009, 22:08
Re: Multithreaded Python
Although python support threads, the interpreter only runs one at at time. So you can't even gain much with threads.
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: Multithreaded Python
C++ is not an option. Would I see some multithreaded gains if I script in C#?
-TS-
-TS-
-
luceric
- Posts: 1252
- Joined: 21 Jun 2009, 22:08
Re: Multithreaded Python
well you can't ask XSI to evaluate in multiple threads.
have you tried caching out the particles, but then writing a script that reads the cache file instead? there is a code on the web for reading ICEcache in python
http://bilzlee.blogspot.ca/
http://code.google.com/p/ice-cache-explorer
have you tried caching out the particles, but then writing a script that reads the cache file instead? there is a code on the web for reading ICEcache in python
http://bilzlee.blogspot.ca/
http://code.google.com/p/ice-cache-explorer
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: Multithreaded Python
Yeah, I knew about the python ICECache reader and that's still an option.luceric wrote:have you tried caching out the particles, but then writing a script that reads the cache file instead?
What does that mean? Does it mean this pseudo code would not work?luceric wrote:well you can't ask XSI to evaluate in multiple threads.
Code: Select all
Thread 1
Array = SIObject.ICEAttribute.GetDataArrayChunk(0, 1000);
Thead 2
Array = SIObject.ICEAttribute.GetDataArrayChunk(1001, 2000);-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: Multithreaded Python
You cannot call the SDK from different worker threads.
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: Multithreaded Python
Oh, okay, it finally clicked after reading some more docs.xsisupport wrote:You cannot call the SDK from different worker threads.
....I found this is some example code
So, they recommend using an event callback in the main thread.XSI SDK wrote:Calling Softimage operations from worker threads may put Softimage in an undefined state.
For anyone else that's learning like me...look at the XSIServer.cs and XSIServiceProvider.cs files in the SDK for a demo.
-TS-
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: Multithreaded Python
The C# SDK is faaaast. I really like the speed I'm seeing, I wrote about 5k particles in XML format out to the file system and it was instant. [position, scale, color, shape, rotation attributes].
