How to write to a named pipe?

Diego Dainese xdsi at
Wed Aug 18 00:08:12 CEST 1999

singlets at writes:
> %: python
> Python 1.5.1 (#1, Mar 21 1999, 22:49:36)  [GCC
> egcs-2.91.66 19990314/Li on linux-i386
> Copyright 1991-1995 Stichting Mathematisch
> Centrum, Amsterdam
>>>> import os
>>>> os.mkfifo('/tmp/myfifo')
>>>> f=open('/tmp/myfifo','w')    # now we're stuck

It is normal that Python hangs when you try to open the fifo for
writing, because the underlying C sys-call hangs waiting for some
process to open the pipe for reading.

The problem is that when Python hangs, it cannot receive signals; I
had the very same problem with the threading API, and the only
solution I found was to do polling.

Does anyone known a better solution?

> Sorry if I'm being an idiot.

I'm sorry too ;)


Diego   | To reply remove the `x' and swap the | Sorry for my
Dainese | words around the `@' in the address. | bad English!

More information about the Python-list mailing list