Run external program in a separate thread

   2835   2   1
User Avatar
Member
345 posts
Joined:
Offline
Hi,

I'm trying to start an external command line program from within houdini session but without blocking the Main thread. How can I achieve that in Python? Thanks.

Kuba
User Avatar
Member
40 posts
Joined: May 2010
Offline
I'm by no means a python programmer yet but

import os;
os.fork( )

appears to offer forking caps in python, according to google.
User Avatar
Member
345 posts
Joined:
Offline
Thanks, it took a while but fortunately sort it out. It is not definitely the most elegant solution, so I appreciate any inspiring alternatives.
Here is the code if anyone interested:


def mainThr():
import time, thread, subprocess
def thr():
i=0
while i < 10:
print i
time.sleep(1)
i=i+1

#a = thread.start_new_thread(thr,())
#thr()

import threading


thread1 = threading.Thread( target=thr, args“”) )
thread1.start()


(Btw. I use this as a funtion for the HDA button)
  • Quick Links