subprocess terminate help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ernesto

    #1

    subprocess terminate help

    def launchWithoutCo nsole(command, args):
    """Launches 'command' windowless and waits until finished"""
    startupinfo = subprocess.STAR TUPINFO()
    startupinfo.dwF lags |= subprocess.STAR TF_USESHOWWINDO W
    return subprocess.Pope n([command] + args,
    startupinfo=sta rtupinfo).wait( )


    handle = launchWithoutCo nsole("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?

  • Fredrik Lundh

    #2
    Re: subprocess terminate help

    Ernesto wrote
    [color=blue]
    > 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?[/color]

    someone calling himself "Ernesto" posted this link yesterday:



    </F>



    Comment

    • Fredrik Lundh

      #3
      Re: subprocess terminate help

      Ernesto wrote
      [color=blue]
      > 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?[/color]

      someone calling himself "Ernesto" posted this link yesterday:



      </F>



      Comment

      • Ernesto

        #4
        Re: subprocess terminate help

        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.

        Comment

        • Ernesto

          #5
          Re: subprocess terminate help

          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.

          Comment

          • Fredrik Lundh

            #6
            Re: subprocess terminate help

            Ernesto wrote:
            [color=blue]
            > 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.[/color]

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

            </F>



            Comment

            • Fredrik Lundh

              #7
              Re: subprocess terminate help

              Ernesto wrote:
              [color=blue]
              > 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.[/color]

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

              </F>



              Comment

              • Ernesto

                #8
                Re: subprocess terminate help

                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!

                Comment

                • Ernesto

                  #9
                  Re: subprocess terminate help

                  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!

                  Comment

                  • Ernesto

                    #10
                    Re: subprocess terminate help

                    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.

                    Comment

                    • Ernesto

                      #11
                      Re: subprocess terminate help

                      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.

                      Comment

                      • Fredrik Lundh

                        #12
                        Re: subprocess terminate help

                        Ernesto wrote
                        [color=blue]
                        > 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.[/color]

                        I have to admit that I have no idea what you're doing, really. The code
                        you used *explicitly* waits for the "program.ex e" 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>



                        Comment

                        • Fredrik Lundh

                          #13
                          Re: subprocess terminate help

                          Ernesto wrote
                          [color=blue]
                          > 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.[/color]

                          I have to admit that I have no idea what you're doing, really. The code
                          you used *explicitly* waits for the "program.ex e" 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>



                          Comment

                          • Do Re Mi chel La Si Do

                            #14
                            Re: subprocess terminate help

                            Hi!

                            Self-destruction of a script:

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

                            (only in windows XP or 2K)


                            @-salutations

                            Michel Claveau



                            Comment

                            • Do Re Mi chel La Si Do

                              #15
                              Re: subprocess terminate help

                              Hi!

                              Self-destruction of a script:

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

                              (only in windows XP or 2K)


                              @-salutations

                              Michel Claveau



                              Comment

                              Working...