problem with opening a new python program in a new window (andkeeping track of the process)

Discussion in 'Python' started by Zak Kinion, Nov 2, 2010.

  1. Zak Kinion

    Zak Kinion Guest

    Hello all,

    What I want to do: launch seperate python programs from one main
    program (multi-threading will not achieve this because the mechanize
    library uses one shared global opener object which will not suit my
    needs) I want the scripts launched to be in seperate windows that i
    can see the output of on screen, seperate processes. I can accomplish
    this in win32 by:

    import subprocess;
    args = ["cmd", "/c", "START", "python", "myScript.py"];
    process1 = subprocess.Popen(args, shell=False);

    however, doing will open a new window, but will lose the process id:

    e.g. process1.poll() will always return 0 no matter if the process is
    open or not, meaning that python always thinks its closed.
    It should return None if the process is still running.

    I can do it without using cmd /c start, but then the newly launched
    python script is trapped in my original cmd terminal where i launched
    the script from in the first place. I can keep track of the process
    now, but the one cmd window open is insufficient to keep track of the
    output that a multitude of programs running will produce. Doing it
    without the /c argument will still keep the new script in the same
    console.

    Yes, I have read I can do this in linux with Konsole or whatever like:
    child = subprocess.Popen("konsole -e python foo.py", shell=True)

    however, I need this to run in windows.


    Any help or solution is appreciated,


    --
    Zak Kinion
     
    Zak Kinion, Nov 2, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige

    Closing child window when opening a new Window

    Patrick Olurotimi Ige, Dec 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    450
    Patrick Olurotimi Ige
    Dec 14, 2004
  2. UJ
    Replies:
    2
    Views:
    7,550
    John Timney \(ASP.NET MVP\)
    Jun 27, 2005
  3. Clara
    Replies:
    6
    Views:
    601
    Clara
    Apr 25, 2005
  4. Joe Van Dyk
    Replies:
    3
    Views:
    223
    Ara.T.Howard
    Jun 25, 2005
  5. Allan
    Replies:
    1
    Views:
    118
    Randy Webb
    Aug 6, 2004
Loading...

Share This Page