[Tutor] subprocess Popen

Weidner, Ronald RWeidner at ea.com
Sat Apr 4 00:03:20 CEST 2009

I have a long running py script that I'm trying to kick off from another long running py script as a separate process... If either script fails or terminates, I don't want the other script to be effected as a result. In other words I need a separate process not a new thread. In any case, this code I thought would work but it doesn't.

someLongRunningScript= ( "%s/someLongRunningScript.py" % ( os.getcwd() ) )
someLongRunningScriptArgs= ( '--verbose --directory=%s --link=%s %s' % ( directory_name, link_name, span_option ) )
longCommand = ( '%s %s' % ( someLongRunningScript, someLongRunningScriptArgs) )
pid = subprocess.Popen ( ["/usr/bin/python", longCommand ] ).pid
print ( "/usr/bin/python %s " % ( longCommand ) )

What's interesting is that if I copy the text printed in the 5th line, paste into my shell, then run it -- the process I'm trying to start works perfectly.

The problem seems to have something to do with the way arguments are being passed to the python script named someLongRunningProcess.py.

Help is greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090403/cd9bfc40/attachment-0001.htm>

More information about the Tutor mailing list