另一种方法(而不是将shell进程放在后台的其他建议)是使用多线程。
run您所拥有的方法将执行以下 *** 作:
thread.start_new_thread ( myFuncThatDoesZGrep)
要收集结果,您可以执行以下 *** 作:
class MyThread(threading.Thread): def run(self): self.finished = False # Your pre to run the command here. blahBlah() # When finished.... self.finished = True self.results = []
如上在多线程链接中所述运行线程。如果您的线程对象具有myThread.finished == True,则可以通过myThread.results收集结果。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)