how to call a program from python without waiting for it to return

元气小坏坏 提交于 2019-11-28 23:11:08
newtover

I posted a solution how to detach a process in a previous question.

By using poll() instead of wait() on Popen it will not block and it won't wait for the program to run. However, I think the only way to really stop the entire program from waiting is by creating a daemonic thread which starts the process. That way you'll never have to wait for it.

class MyThread(threading.Thread):
    def run(self):
        '''Start your thread here'''
        pass

thread = MyThread()
thread.daemon = True
thread.start()

Under Windows, if you invoke the program using the shell START command you should be able to "release" the parent process and allow it to exit. Try START /? at the DOS prompt to learn more.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!