Search - User list
Full Version: Houdini crashes every time I cook the Python Script like this, but works fine when I cook workitem one by one
Root » PDG/TOPs » Houdini crashes every time I cook the Python Script like this, but works fine when I cook workitem one by one
EricSheng

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:
chrisgreb
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:

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
Hi, Chris:
Thank you for your quick reply and the explanation is quite clear.
But I've never heard the module “hdefereval” before, and I want to get more knowledge in depth, is there any documentation to explain this function?
Thank you again.
chrisgreb
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB