FAQ

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);
Pass CREATE_NEW_CONSOLE as one of the creationflags:

<code>
import os, sys

Yep, that definitely works. :)

import subprocess

processes = []
cmd = [sys.executable, "-c", "import os; print os.getpid (); raw_input ()"]
for i in range (3):
?processes.append (subprocess.Popen (cmd, creationflags=subprocess.CREATE_NEW_CONSOLE))

#
# Keep looping round to see the current status
#
while True:
?for p in processes:
? ?print p.poll ()

?raw_input ()

</code>

TJG


--
http://mail.python.org/mailman/listinfo/python-list


--
Zak Kinion
zkinion at gmail.com
(702) 287-5613

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 3, '10 at 10:46p
activeNov 3, '10 at 10:46p
posts1
users1
websitepython.org

1 user in discussion

Zak Kinion: 1 post

People

Translate

site design / logo © 2022 Grokbase