I\'m currently launching a programme using subprocess.Popen(cmd, shell=TRUE)
I\'m fairly new to Python, but it \'feels\' like there ought to be some api
I had same problem, and solved it using multiprocessing.Pool. There are two hacky tricks involved:
result is one function executed with callback on completion
def sub(arg):
print arg #prints [1,2,3,4,5]
return "hello"
def cb(arg):
print arg # prints "hello"
pool = multiprocessing.Pool(1)
rval = pool.map_async(sub,([[1,2,3,4,5]]),callback =cb)
(do stuff)
pool.close()
In my case, I wanted invocation to be non-blocking as well. Works beautifully