Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: os.pipe() + os.fork()

Reply
Thread Tools

Re: os.pipe() + os.fork()

 
 
Gary Herron
Guest
Posts: n/a
 
      02-20-2010
Sebastian Noack wrote:
> I have figured out that, you have to close the writing end in the child
> process, which is reading from the pipe. Otherwise the underlying pipe
> is not going to be closed when the parent process is closing its
> writing end. This has nothing to do with Python itself. I have tried
> plain C and there it is the same behaviour.
>
> Regards
> Sebastian Noack
>



Correct. The fork creates two processes with references to the read and
write ends of the pipe. Both parent and child processes should close
the ends they are not using.

Here's a thought: Consider the subprocess module. It can do the fork
and any necessary pipes and can do so in an OS independent way. It
might make you life much easier.

Gary Herron

 
Reply With Quote
 
 
 
 
sebastian.noack@googlemail.com
Guest
Posts: n/a
 
      02-23-2010
On Feb 20, 8:13*pm, Gary Herron <(E-Mail Removed)> wrote:
> Here's a thought: *Consider the subprocess module. * It can do thefork
> and any necessary pipes and can do so in an OS independent way. * It
> might make you life much easier.


As far as i know the subprocess module provides only functionality for
running any program as subprocess. But I just want to fork the current
process without putting some code in an external python script.

Sebastian Noack
 
Reply With Quote
 
 
 
 
Aahz
Guest
Posts: n/a
 
      02-25-2010
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
>On Feb 20, 8:13=A0pm, Gary Herron <(E-Mail Removed)> wrote:
>>
>> Here's a thought: =A0Consider the subprocess module. =A0 It can do thefor=

>k
>> and any necessary pipes and can do so in an OS independent way. =A0 It
>> might make you life much easier.

>
>As far as i know the subprocess module provides only functionality for
>running any program as subprocess. But I just want to fork the current
>process without putting some code in an external python script.


Then try multiprocessing
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments