non blocking named pipes

Peter Hansen peter at
Mon Jun 23 18:28:22 CEST 2003

Yves Serrano wrote:
> I have a problem with named pipes....
> I searched in the web, but don't found any working solution....
> My Problem is that I have a pipe (/temp/pipe) where sometimes some data
> ist written into, but not very often.
> I try to write a python script that opens the pipe and gets the data if
> its there. I no data is there the script
> should not block, it should immediately exit without data.
> How to do that?
> I'm using python 2.2 on linux

There may be a better way, but the function is probably
capable of doing what you need.  Just give it timeout parameter of 0
to avoid blocking.

mypipe = open-my-pipe(/temp/pipe)

dr, dw, de = select([mypipe], [], [], 0)
if dr == [mypipe]:
    # read from mypipe here...


More information about the Python-list mailing list