Named pipe is not flushing in Python

Posted by BrainCore on Stack Overflow See other posts from Stack Overflow or by BrainCore
Published on 2010-01-26T00:40:43Z Indexed on 2010/03/24 15:13 UTC
Read the original article Hit count: 465

Filed under:
|
|
|
|

I have a named pipe created via the os.mkfifo() command. I have two different Python processes accessing this named pipe, process A is reading, and process B is writing. Process A uses the select function to determine when there is data available in the fifo/pipe. Despite the fact that process B flushes after each write call, process A's select function does not always return (it keeps blocking as if there is no new data). After looking into this issue extensively, I finally just programmed process B to add 5KB of garbage writes before and after my real call, and likewise process A is programmed to ignore those 5KB. Now everything works fine, and select is always returning appropriately. I came to this hack-ish solution by noticing that process A's select would return if process B were to be killed (after it was writing and flushing, it would sleep on a read pipe). Is there a problem with flush in Python for named pipes?

© Stack Overflow or respective owner

Related posts about python

Related posts about named-pipes