spawn background process and detach it w/o problems

davisn90210 at gmail.com davisn90210 at gmail.com
Thu Nov 8 14:07:35 EST 2007


On Nov 8, 8:09 am, "Dmitry Teslenko" <dtesle... at gmail.com> wrote:
> Hello!
> How to write portable (win32, unix) script that launches another
> program and continues its execution?
>
> I've looked at spawn*() but it doesn't look in PATH dirs on windows so
> it's totally unusable when you don't know where exactly program is.
>
> I've looked at fork() way but there's no fork for windows.
>
> My current solution is
> thread.start_new(os.system, (<here's program to launch>,))
>
> It's ugly and there's one big unpleasant pecularity:
> in case there were any os.chdir()-s between beginning of script
> execution and that thread.start_new() then new thread starts in
> original directory. Not in current directory at moment of
> thread.start_new()

Take a look at the subprocess module.




More information about the Python-list mailing list