Home > other > Python call an external application and return immediately
Python call an external application and return immediately
Time:11-17
I call an external application in python, I found not make, my goal is to call the external program let it run alone there, and a host program is completely independent of two programs, but I test, but not what I want effect, In order to facilitate the narrative below, python program called p, called program called c program, called with a parameter, as follows: The path of the exePath: c program ParString: argument string
I tested a few ways, the result is as follows: OS. Execv (exePath parString), p program will be shut down, c program can start, but can't get the right parameter Ditto for your OS. Execl (exePath parString) OS. Execle (exePath parString), c program is not running, p program crashes OS. Execlp (exePath parString), p program will be shut down, c program can start, but can't get the right parameter Ditto for your OS. Execvp (exePath parString) OS. Execlpe (exePath parString), c program is not running, p program crashes OS. Startfile (exePath + "" + parString), ditto OS. The system (exePath + "" + parString), c programs can run normally, but before the end of the c program, p no response From the test results, the most close to the target is the last one, OS, system (), but before the end of the c program, p application could not continue to run, it is very good, Do not know to have what interface can achieve my goal, in other words, there is no such interface?
CodePudding user response:
Can try solve with multithreading, open a new thread to invoke the OS. The system (XXXX), don't directly in the main thread to execute the OS. The system So give it a try and see can solve the problem of p application no response