question, has anyone tried to run muiltiple instances of hou.hipFile.load() in individual threads, outside houdini?
Whatever I do, it shares the same hipFile accross all my threads
cheers
hou.hipFile.load() in multiple threads
2584 4 0- holycause
- Member
- 12 posts
- Joined: Dec. 2011
- Offline
- Enivob
- Member
- 2540 posts
- Joined: June 2008
- Offline
- holycause
- Member
- 12 posts
- Joined: Dec. 2011
- Offline
I have my thread Class that loads a hipfile
class GetNodesThread(QtCore.QThread):
send_node = QtCore.pyqtSignal(object)
def __init__(self, file, parent, v):
self.m_file = file
…..
def run(self):
hou.hipFile.load(self.m_file)
and then in my main script create 1 thread for each file
#Thread 1
thread1 = HThreads.GetNodesThread(self.m_file1, self, 1)
#thread1.send_node.connect(lambda x: self.getObjLists(1, x))
self.m_threads.append(thread1)
#Thread 2
thread2 = HThreads.GetNodesThread(self.m_file2, self, 2)
#thread2.send_node.connect(lambda y: self.getObjLists(2, y))
self.m_threads.append(thread2)
#Start threads
for thread in self.m_threads:
thread.start()
I have some additional debugging code writing out information regarding the loaded files and this is what happens
/path/to/the/hipfile - loaded_hipefile
Thread 1:
Pre load
Zdevel/python/hipfile_diff_check/hip/sphere_v1.hip - untitled.hip
Loaded
Zdevel/python/hipfile_diff_check/hip/sphere_v1.hip - sphere_v2.hip
Wrong file
Thread 2:
Pre load
Zdevel/python/hipfile_diff_check/hip/sphere_v2.hip - untitled.hip
Loaded
Zdevel/python/hipfile_diff_check/hip/sphere_v2.hip - sphere_v2.hip
Correct file
class GetNodesThread(QtCore.QThread):
send_node = QtCore.pyqtSignal(object)
def __init__(self, file, parent, v):
self.m_file = file
…..
def run(self):
hou.hipFile.load(self.m_file)
and then in my main script create 1 thread for each file
#Thread 1
thread1 = HThreads.GetNodesThread(self.m_file1, self, 1)
#thread1.send_node.connect(lambda x: self.getObjLists(1, x))
self.m_threads.append(thread1)
#Thread 2
thread2 = HThreads.GetNodesThread(self.m_file2, self, 2)
#thread2.send_node.connect(lambda y: self.getObjLists(2, y))
self.m_threads.append(thread2)
#Start threads
for thread in self.m_threads:
thread.start()
I have some additional debugging code writing out information regarding the loaded files and this is what happens
/path/to/the/hipfile - loaded_hipefile
Thread 1:
Pre load
Zdevel/python/hipfile_diff_check/hip/sphere_v1.hip - untitled.hip
Loaded
Zdevel/python/hipfile_diff_check/hip/sphere_v1.hip - sphere_v2.hip
Wrong file
Thread 2:
Pre load
Zdevel/python/hipfile_diff_check/hip/sphere_v2.hip - untitled.hip
Loaded
Zdevel/python/hipfile_diff_check/hip/sphere_v2.hip - sphere_v2.hip
Correct file
Lead FX TD - Weta Digital
- GuillaumeJ
- Member
- 23 posts
- Joined: Sept. 2015
- Offline
Have you tried with the multiprocessing lib instead ?
https://docs.python.org/2/library/multiprocessing.html [docs.python.org]
https://docs.python.org/2/library/multiprocessing.html [docs.python.org]
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
- holycause
- Member
- 12 posts
- Joined: Dec. 2011
- Offline
-
- Quick Links