[Tutor] os.system() with NO_WAIT

wesley chun wescpy at gmail.com
Mon Aug 7 22:28:11 CEST 2006


>         os.system('vedicom.exe')
>
> Have you got any idea how I can strart this windows GUI program with not
> waiting its return.

instead of os.system(), you want to use the subprocess module if you
are using Python 2.4+:
http://docs.python.org/lib/module-subprocess.html

calling subprocess.Popen(["/bin/mycmd", "myarg"]) is "no wait."

to save the PID:

pid = subprocess.Popen(["/bin/mycmd", "myarg"]).pid

if you are using Python 2.3.x and older, you have to use spawn*():

pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list