Need to create subprocess...

D

drstoka

Hello,

I have to run a program as a child process inside my python program and
redirect it's output through a pipe to a parent program process.
So, I wrote this:

pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout

and it works great.

Now, in parent program I need to wait for a some time and if a child
(example_program) does not finish in that time, kill the child.

How do I do that? Please help.
 
M

Martin P. Hellwig

Hello,

I have to run a program as a child process inside my python program and
redirect it's output through a pipe to a parent program process.
So, I wrote this:

pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout

and it works great.

Now, in parent program I need to wait for a some time and if a child
(example_program) does not finish in that time, kill the child.

How do I do that? Please help.
Try searching around for "threading.thread python" it should give you
some clues, if you can't work through the info (it can be a bit hard to
digest), just post here an example of your test code along with what you
expected and what didn't happen.
 
P

Patrick Maupin

Hello,

I have to run a program as a child process inside my python program and
redirect it's output through a pipe to a parent program process.
So, I wrote this:

pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout

and it works great.

Now, in parent program I need to wait for a some time and if a child
(example_program) does not finish in that time, kill the child.

How do I do that? Please help.

I have a module that does this and more, but it only works on Linux:

http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/tests/execmgr.py

For usage examples, you can just execute it. Also, see autotest.py in
the same directory.

Regards,
Pat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top