I know this is an old question, but here is a version that has not come to a standstill.
import os, threading
def Writer(pipe, data):
pipe.write(data)
pipe.flush()
readEnd, writeEnd = os.pipe()
readFile = os.fdopen(readEnd)
writeFile = os.fdopen(writeEnd, "w")
thread = threading.Thread(target=Writer, args=(writeFile,"one line\n"))
thread.start()
firstLine = readFile.readline()
print firstLine
thread.join()
source
share