improving performance of writing into a pipe

Michael Torrie torriem at
Tue Feb 19 18:47:16 CET 2013

On 02/19/2013 02:24 AM, mikprog at wrote:
> Or rather: what would you try to catch in this particular case?

As Peter said, nothing for now.  But you seem very resistant to telling
us what exception was raised.

Though looking at your code more closely I can see that likely the error
is related to the fact that /tmp/mypipe is not an executable program.
popen (which is deprecated and replaced by the subprocess module) is for
running programs and communicating with them over pipes created by the
popen function.  So your code is not likely to ever work as it is
presently given.

Here's the bash equivalent of your code:

$ mkfifo /tmp/path
$ cat </tmp/path &
$ echo hello, world | /tmp/path

Bash will say, "bash: /tmp/path: Permission denied"

The correct bash line is:
$ echo hello, world > /tmp/path

popen() (and subprocess) is the equivalent of the first bash command.
open() is the equivalent of the second line.

Do you understand the difference?

More information about the Python-list mailing list