<i id='1t0Xk'><tr id='1t0Xk'><dt id='1t0Xk'><q id='1t0Xk'><span id='1t0Xk'><b id='1t0Xk'><form id='1t0Xk'><ins id='1t0Xk'></ins><ul id='1t0Xk'></ul><sub id='1t0Xk'></sub></form><legend id='1t0Xk'></legend><bdo id='1t0Xk'><pre id='1t0Xk'><center id='1t0Xk'></center></pre></bdo></b><th id='1t0Xk'></th></span></q></dt></tr></i><div id='1t0Xk'><tfoot id='1t0Xk'></tfoot><dl id='1t0Xk'><fieldset id='1t0Xk'></fieldset></dl></div>

      <legend id='1t0Xk'><style id='1t0Xk'><dir id='1t0Xk'><q id='1t0Xk'></q></dir></style></legend>
        <bdo id='1t0Xk'></bdo><ul id='1t0Xk'></ul>

      <small id='1t0Xk'></small><noframes id='1t0Xk'>

    1. <tfoot id='1t0Xk'></tfoot>

      如何从 python 调用程序而不等待它返回

      how to call a program from python without waiting for it to return(如何从 python 调用程序而不等待它返回)

        <bdo id='huVQz'></bdo><ul id='huVQz'></ul>

          <tfoot id='huVQz'></tfoot>

          <small id='huVQz'></small><noframes id='huVQz'>

                <tbody id='huVQz'></tbody>
            • <i id='huVQz'><tr id='huVQz'><dt id='huVQz'><q id='huVQz'><span id='huVQz'><b id='huVQz'><form id='huVQz'><ins id='huVQz'></ins><ul id='huVQz'></ul><sub id='huVQz'></sub></form><legend id='huVQz'></legend><bdo id='huVQz'><pre id='huVQz'><center id='huVQz'></center></pre></bdo></b><th id='huVQz'></th></span></q></dt></tr></i><div id='huVQz'><tfoot id='huVQz'></tfoot><dl id='huVQz'><fieldset id='huVQz'></fieldset></dl></div>

            • <legend id='huVQz'><style id='huVQz'><dir id='huVQz'><q id='huVQz'></q></dir></style></legend>

                本文介绍了如何从 python 调用程序而不等待它返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有没有办法从 python 调用程序而不等待它返回?我创建了一个脚本,它将程序复制到目录并运行该程序.但是当我从 python 调用程序时,python 脚本在我启动的程序退出之前不会退出.我试过 os.system 和 Popen.还有其他方法吗?

                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 call the program from python, the python script does not exit until the program i launched exits. i have tried os.system and Popen. is there another way to do this?

                添加信息:os.spawnl 和 os.P_DETACH 仍然不起作用;根据文档,P_DETACH 类似于 P_NOWAIT,但新进程与调用进程的控制台分离".但它仍然以某种方式附加到我的调用进程(调用脚本在任何被调用的可执行文件返回之前不会退出)

                Added info: os.spawnl with os.P_DETACH still doesn't work; according to the docs, "P_DETACH is similar to P_NOWAIT, but the new process is detached from the console of the calling process". but it is still somehow attached to my calling process (calling script won't quit until any of the called executables return)

                程序:

                os.system("start test.exe")
                print "Done"
                

                在它执行 test.exe 之后,它会打印 Done.但它不会终止脚本的执行(脚本进程仍在运行).尝试创建一个守护线程并使用 P_DETACH Popen,仍然不行.

                after it executes test.exe, it prints Done. but it does not terminate the script's execution (script process still running). tried creating a daemon thread and Popen with a P_DETACH, still no go.

                推荐答案

                在 Windows 下,如果你使用 shell START 命令调用程序,你应该能够释放"父进程并允许它退出.在 DOS 提示符下尝试 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.

                这篇关于如何从 python 调用程序而不等待它返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                  <tbody id='bVIIa'></tbody>

                <small id='bVIIa'></small><noframes id='bVIIa'>

              1. <legend id='bVIIa'><style id='bVIIa'><dir id='bVIIa'><q id='bVIIa'></q></dir></style></legend>
                    • <bdo id='bVIIa'></bdo><ul id='bVIIa'></ul>

                      <tfoot id='bVIIa'></tfoot>

                          <i id='bVIIa'><tr id='bVIIa'><dt id='bVIIa'><q id='bVIIa'><span id='bVIIa'><b id='bVIIa'><form id='bVIIa'><ins id='bVIIa'></ins><ul id='bVIIa'></ul><sub id='bVIIa'></sub></form><legend id='bVIIa'></legend><bdo id='bVIIa'><pre id='bVIIa'><center id='bVIIa'></center></pre></bdo></b><th id='bVIIa'></th></span></q></dt></tr></i><div id='bVIIa'><tfoot id='bVIIa'></tfoot><dl id='bVIIa'><fieldset id='bVIIa'></fieldset></dl></div>