In message
<[EMAIL PROTECTED]>, Iain
wrote:

> Well I did work out *a* solution this way:
> 
>   pipename = os.tmpnam()
>   os.mkfifo(pipename)
>   pid = os.fork()
>   if pid==0:
>     fifoobj = open(pipename,"w")
>     fifoobj.write(streamobj.read())
>     fifoobj.close()
>     os.unlink(pipename)
>   else:
>     TroublesomeFunction(pipename)

OK, so TroublesomeFunction is reading from the pipe while the child is
writing? Naturally you'd get a block if you tried to do both in the same
process.

> And it doesn't fail very gracefully in that if
> TroublesomeFunction stops before attempting to open/read the pipe,
> then the child process stays hung waiting for the other end of the
> pipe to open.

Perhaps the parent should open the pipe for reading, before calling
TroublesomeFunction. If the parent then dies, the child will get a "broken
pipe" signal, which by default should kill it.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to