Launching Python from Python

chris liechti cliechti at mails.ch
Fri Jul 27 15:30:35 EDT 2001


do you realy need separate python interpreters?
you could "import" the other module and run the main function in a thread
look at the module "Threading".

something like that:
------
import threading
import test
t = threading.Thread( target=test.main )
t.start()
------
the test.main function runs then in the background

chris


Jay O'Connor <oconnor at bioreason.com> wrote in 
news:3B619A9E.9E940B28 at bioreason.com:

> All,
> 
> I'm trying to launch another program from a Python program.  The other
> program happens to be another Python program.  I thought spawnle would
> be the proper place.  However, it doesn't seem to be working.
> 
>      import os
>      pid = os.spawnle (os.P_NOWAIT,
>                "c:\\python20\\python.exe",
>                ["c:\\james\\development\\python\\test.py"],
>                {"PYTHONPATH":"c:\\james\\python"})
> 
> my understanding is that this should spawn the other process, running
> the python runtime and passing in my script name.
> 
> However, it doesn't quite happen.  What happens is that it launches
> python in interactive mode.  If I import sys, sys.path has my added path
> above, buy sys.argv is an array with one empty string.
> 
> Any ideas why it doesn't work?  Any other ideas on how to launch another
> python program from within one?
> 
> This is on WinNT, BTW
> 
> Take care,
> Jay O'Connor
> oconnor at bioreason.com
> 



-- 
chris <cliechti at mails.ch>




More information about the Python-list mailing list