newbie help: best way manage subprocesses

Paul Sherwood p.sherwood at dl.ac.uk
Fri Mar 28 04:56:31 EST 2003


Hi,

Could someone give me some pointers to the best way of managing
subprocesses on UNIX and Windows.

I am currently using variants of os.popen called from a thread created by
threading.Thread() but as far as I can see there is no obvious way to
destroy
a thread (or the process it controls) if the command it is running does
not complete as expected.

If I use the variants of os.spawn I can run the new processes in the
background
and manage them using the PID that is returned but in this case I don't have
file descriptors for stdout and stderr, which I would like to manipulate.

Am I misunderstanding how to use popen and spawn, or are there other
approaches.  Am I overoptimistic looking for a cross-platform solution (
since maybe something like pexpect will help on Unix)?

many thanks,

Paul Sherwood
CLRC Daresbury Laboratory







More information about the Python-list mailing list