I have a Python file which starts a new process via Popen. The Python codes should wait until this new process is complete before resuming it's code. However, the process Python starts also spawns another cmd.exe window which does some work, but stays open after it's done. The process Python starts does close after it's done, but the stay cmd.exe window remains open causing my Python program not to continue. What are the best ways to close this stay window?
Here's the call I'm making to popen:
p = Popen(command, stdout=PIPE, stderr=STDOUT, stdin=PIPE)
command is running another python file. I set it equal to p because I later communicate with the new process via grep_stdout.
This can be solved by using pythonw.exe
instead of python.exe
to execute your second script. If you're running the script directly (rather than invoking the interpreter yourself), you should rename it with a .pyw
file extension, as that should be associated with pythonw.exe
by default.
See this section of the Python docs for more information about executing Python files on Windows.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.