Houdini crashes every time I cook the Python Script like this, but works fine when I cook workitem one by one
3365 3 2- EricSheng
- Member
- 159 posts
- Joined: Feb. 2018
- Offline
As you can see in the python code, I try to create some nodes inside sop net through pdg python script, I'm not sure if this is the right way to use tops but the HDA Processor is just too slow to generate. So I try some weird ways like this.
So It works fine when I generate one by one, but it crashes when I generate them all.
sometimes I can catch some crash log which is like this:
Edited by EricSheng - June 21, 2019 09:55:33
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
No, this is not a supported workflow, the reason is that the pythonscript workitems cook in parallel and off the main thread, and this will cause mayhem and probably crash if the functions they use are not thread safe.
Using the houdini command chain would probably be a safer way to go.
Otherwise, you could force your code run on the main thread like so:
Using the houdini command chain would probably be a safer way to go.
Otherwise, you could force your code run on the main thread like so:
import hou import hdefereval # BAD # hou.node('/obj/box1').createNode('heightfield_file') def doit(): n = hou.node('/obj/box1').createNode('heightfield_file') n.parm('filename').set('$HIP/test') hdefereval.executeInMainThreadWithResult(doit)
- EricSheng
- Member
- 159 posts
- Joined: Feb. 2018
- Offline
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
There isn't any documentation, other than a mention that you can use it to defer work until after a dialog is dismissed. It works in this case because it forces the code to run in series on the main thread. Houdini Command Chain with a for loop and command send would work without modifying your running session of Houdini. Let me know if you'd like to see an example of that.
-
- Quick Links