When executed, the following code will produce this output:
import threading
def runThread():
print hou.time()
threads =
print “Begin”
for i in range(3):
t = threading.Thread(target=runThread)
threads.append(t)
t.start()
print “End”
>>> Begin
End
0.0
0.0
0.0
Without calling the join() function, I am able to use any command in the hou module and have Houdini continue to run correctly. Sometimes threads will take longer than others, so changing attributes might pop in once the threads are done cooking.
However, I want to be able to have the Python SOP wait for all of the threads to finish, before it finished its cooking operation.
I want an output like this:
>>> Begin
0.0
0.0
0.0
End
However, if I call join() it will die if and only if any hou command was called.
For example, the following code dies.
import threading
def runThread():
print hou.time()
threads =
print “Begin”
for i in range(3):
t = threading.Thread(target=runThread)
threads.append(t)
t.start()
for t in threads:
t.join()
print “End”
But the following does this:
import threading
def runThread(i):
print i
threads =
print “Begin”
for i in range(3):
t = threading.Thread(target=runThread, args
i,))threads.append(t)
t.start()
print “End”
>>> Begin
0
1
2
End
This is telling me something in the hou module is dying or reaching an infinite loop when hou commands are called in parallel. Any help would be much appreciated. Thanks

