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

后端 未结 3 1424
一整个雨季
一整个雨季 2020-12-14 16:36

is there a way to call a program from python without waiting for it to return? i created a script which copies a program to a directory and runs that program. but when i cal

相关标签:
3条回答
  • 2020-12-14 16:56

    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()
    
    0 讨论(0)
  • 2020-12-14 17:09

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

    0 讨论(0)
  • 2020-12-14 17:17

    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.

    0 讨论(0)
提交回复
热议问题