Python Multiprocessing in Houdini

   1065   2   1
User Avatar
Member
35 posts
Joined: Dec. 2012
Offline
is it possible to run this code using a python node? Every time I try to run the code Houdini ends up freezing. Seems like you can't use the multiprocessing module does anyone know if this is the case?

import hou
from multiprocessing import Pool

def create_geo(type):
    node = hou.node("/obj/geo1")

def demo():
    type = ["sphere", "tube", "box"]
    with Pool() as pool:
        pool.map(create_geo, type)

def main():
    demo()

main()
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
No that's not going to work for a multitude of reasons. The multiprocessing module is spinning up a bunch of child processes to perform the work, and so the computed result has to be returnable to the parent process as a value. Your example tries to create a new node in the child process which (even if it worked via a correctly bootstrapped hython process) couldn't be passed back to Houdini as a value.

A python node is even further restricted - you're expected to only change the data local to the node. Exactly what that data is varies by context.
Edited by antc - Aug. 18, 2022 15:16:24
User Avatar
Member
35 posts
Joined: Dec. 2012
Offline
ah ok got it. Thank you
  • Quick Links