子进程终止帮助 [英] subprocess terminate help
问题描述
def launchWithoutConsole(command,args):
"""启动''命令''无窗口并等待直到完成""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags | = subprocess.STARTF_USESHOWWINDOW
返回subprocess.Popen([command] + args,
startupinfo = startupinfo).wait()
handle = launchWithoutConsole(" program.exe",[" disconnect"])
--------- -------------------------------------------------- -------------------------------------------------- -----------------
我一直在寻找终止这个过程的方法,所以我可以退出我的
计划。 program.exe是一个基于文本的界面,我在DOS命令窗口中运行了
python子进程。我尝试使用''sys.exit()''
来结束我的程序,但没有任何作用。我想我必须以某种方式
终止我创建的子进程。有什么建议吗?
def launchWithoutConsole(command, args):
"""Launches ''command'' windowless and waits until finished"""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.Popen([command] + args,
startupinfo=startupinfo).wait()
handle = launchWithoutConsole("program.exe",["disconnect"])
------------------------------------------------------------------------------------------------------------------------------
I''ve been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I''m running with
python subprocess in a DOS command window. I tried using ''sys.exit()''
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?
推荐答案
Ernesto写道
Ernesto wrote
我一直在寻找方法终止此过程,以便我可以退出我的
程序。 program.exe是一个基于文本的界面,我在DOS命令窗口中运行了蟒蛇子进程。我尝试使用''sys.exit()''
结束我的程序,但没有任何作用。我想我必须以某种方式
终止我创建的子进程。有什么建议吗?
I''ve been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I''m running with
python subprocess in a DOS command window. I tried using ''sys.exit()''
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?
有人自称Ernesto昨天发布此链接:
http ://aspn.activestate.com/ASPN/Coo.../Recipe/347462
someone calling himself "Ernesto" posted this link yesterday:
http://aspn.activestate.com/ASPN/Coo.../Recipe/347462
</F>
Ernesto写道
Ernesto wrote
我一直在寻找终止这个过程的方法,所以我可以退出我的
程序。 program.exe是一个基于文本的界面,我在DOS命令窗口中运行了蟒蛇子进程。我尝试使用''sys.exit()''
结束我的程序,但没有任何作用。我想我必须以某种方式
终止我创建的子进程。有什么建议吗?
I''ve been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I''m running with
python subprocess in a DOS command window. I tried using ''sys.exit()''
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?
有人自称Ernesto昨天发布此链接:
http ://aspn.activestate.com/ASPN/Coo.../Recipe/347462
someone calling himself "Ernesto" posted this link yesterday:
http://aspn.activestate.com/ASPN/Coo.../Recipe/347462
</F>
是的,我知道。我发布了它b / c我遇到了同样的问题而且我是b / b
调查方法这样做。这些方法都没有给我所需的
我的程序的结果。我想做的就是结束我的python程序和
返回DOS提示符。
Yeah I know. I posted it b/c I was having the same problems and I''m
investigating ways to do this. None of those methods gave me desired
results for my program. All I want to do is end my python program and
return to the DOS prompt.
这篇关于子进程终止帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!