[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Need to create subprocess...

dr_stoka

3/18/2010 4:17:00 PM

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.


2 Answers

Martin P. Hellwig

3/18/2010 5:26:00 PM

0

On 03/18/10 16:17, drstoka wrote:
> 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.

--
mph

Patrick Maupin

3/18/2010 5:30:00 PM

0

On Mar 18, 11:17 am, "drstoka" <filip.popravi.stojmeno...@fer.hr>
wrote:
> 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/...

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

Regards,
Pat