Situation:
new_pipe = os.open(pipe_path, os.O_RDONLY | os.O_NONBLOCK) # pipe_path points to a FIFO
data = os.read(new_pipe, 1024)
The read occasionally raises errno -11: Resource temporarily unavailable.
When is this error raised? It seems very rare, as the common cases return data:
- If no writer has the pipe opened, empty str (”) is returned.
- If the writer has the pipe opened, but no data is in the fifo, empty str
(”) is also returned - And of course if the writer puts data in the fifo, that data will be read.
From the POSIX specification of the
readsystem call (emphasis mine):So basically your second assumption is wrong:
This would be against the specification and I can’t reproduce that behaviour on my machine (it raises
EAGAINfor me). This is not a big problem however, you can just catch the exception and retry: