Python open a named pipe == hanging?
Donn Cave
donn at u.washington.edu
Fri Aug 4 13:25:51 EDT 2006
In article <op.tdrmzdd1h12lye at cadet.mshome.net>,
Rochester <rochester1976 at gmail.com> wrote:
> Thank you for your advise. So, it turns out that fifos are quite useless
> in Python programming then, which is quite disappointing to me :-(
>
> I am not saying that I _have to_ use fifo, afterall it is a rather odd
> thingy not in fasion since the last iceage... I am just disappointed by
> the fact that the old plain Bash seems to excel Python in this special
> aspect.
Not by a very great margin, but it is indeed very convenient
for process creation and redirection, so when that's the
nature of the task, it's likely the right choice.
> I am new to Python and much more comfortable in Bash programming. A
> simple Bash script like this would take the advantage of a fifo, hence
> reduce the overhead of unneccesarry temporary files creation:
>
> #!/bin/bash
>
> mkfifo my_fifo
> echo "this is a string in my fifo!" > my_fifo &
> cat my_fifo
> rm my_fifo
>
> Isn't it neat?
If you like it, good for you. Do you understand why it
works, when your Python one didn't? You put the output
in a background process; did it occur to you to try that
in Python?
> Anyway, I think every scripting language has its pros and cons. Bash is
> probably more flexible in dealing with fifos and multiway pipes (through
> the magic menchanism of process substitution).
Multiway pipes?
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list