I have three files: myfifo.py
which is named-pipe, writer.py
:
path = "myfifo.py"
fifo = open(path)
for i in range(1,4):
fifo.write( "print %d" % i )
fifo.close()
and reader.py
:
path = "myfifo.py"
execfile(path)
If I execute the reader-file ./reader.py
and then - the writer (in other terminal) ./writer.py
I get the expected result:
1
2
3
But why it works?
Question: Does execfile
open myfifo.py
? And does it close it? What practice is recommended here? I mean should I close the FiFo
in both client and server files?