I'd like to use anonymous pipes to communicate pickled objects between two processes in linux. I don't want to use the subprocess module and instead manually create the necessary pipes and then call pickle.dump and pickle.load. The last two functions, however, require a file object. So, while testing things around, I was faced with the following problem. The following code works fine:
import os
r, w = os.pipe()
os.write(w, b"test")
os.read(r, 1024)
but this code stalls at the read operation
import os
r, w = os.pipe()
fr = os.fdopen(r, "rb")
fw = os.fdopen(w, "wb")
fw.write(b"test")
fr.read()
Additionally, select.select([r],[],[],0) shows the pipe is empty. My question: what is going on during file object creation and why doesn't it work for pipes? Is there a way to get a file object this way at all?