469,951 Members | 2,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

subprocess terminate help

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?

Nov 22 '05 #1
14 3486
Ernesto wrote
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?


someone calling himself "Ernesto" posted this link yesterday:

http://aspn.activestate.com/ASPN/Coo.../Recipe/347462

</F>

Nov 22 '05 #2
Ernesto wrote
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?


someone calling himself "Ernesto" posted this link yesterday:

http://aspn.activestate.com/ASPN/Coo.../Recipe/347462

</F>

Nov 22 '05 #3
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.

Nov 22 '05 #4
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.

Nov 22 '05 #5
Ernesto wrote:
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.


what about the other program? do you want to terminate that as well ?

</F>

Nov 22 '05 #6
Ernesto wrote:
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.


what about the other program? do you want to terminate that as well ?

</F>

Nov 22 '05 #7
Ahhhh... I figured out a way around this. I'll use program.exe to shut
down itself. That way I won't have to use any extension modules.

Thanks!

Nov 22 '05 #8
Ahhhh... I figured out a way around this. I'll use program.exe to shut
down itself. That way I won't have to use any extension modules.

Thanks!

Nov 22 '05 #9
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.

Nov 22 '05 #10
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.

Nov 22 '05 #11
Ernesto wrote
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.


I have to admit that I have no idea what you're doing, really. The code
you used *explicitly* waits for the "program.exe" program to finish. If
you don't want that, why are you telling the subprocess module to wait?
If you do want it to wait, why are you killing the python process ?

</F>

Nov 22 '05 #12
Ernesto wrote
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.


I have to admit that I have no idea what you're doing, really. The code
you used *explicitly* waits for the "program.exe" program to finish. If
you don't want that, why are you telling the subprocess module to wait?
If you do want it to wait, why are you killing the python process ?

</F>

Nov 22 '05 #13
Hi!

Self-destruction of a script:

import os
os.popen('TASKKILL /PID '+str(os.getpid())+' /F')

(only in windows XP or 2K)
@-salutations

Michel Claveau

Nov 22 '05 #14
Hi!

Self-destruction of a script:

import os
os.popen('TASKKILL /PID '+str(os.getpid())+' /F')

(only in windows XP or 2K)
@-salutations

Michel Claveau

Nov 22 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by jelle | last post: by
1 post views Thread by py | last post: by
reply views Thread by Ernesto | last post: by
6 posts views Thread by Ernesto | last post: by
11 posts views Thread by 7stud | last post: by
9 posts views Thread by Phoe6 | last post: by
1 post views Thread by | last post: by
6 posts views Thread by John Mechaniks | last post: by
5 posts views Thread by thedsadude | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.