0

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?

LRDPRDX
  • 631
  • 1
  • 11
  • 23
  • 1
    It's not really clear what you're asking. What is the behaviour you expect? What happens? How do they differ? etc. – pvg Jun 06 '17 at 08:56
  • I think my question(s) are clear. `FiFo` (as I know) is allowed to be used iff both ends (writer and reader) use it. So my question is If program is working then *Does `execfile()` open file?* And if so how to close file after execution? – LRDPRDX Jun 06 '17 at 09:02
  • Well. The thing is, the clarity of a given question depends on whether other people, rather than you, think it's clear. It seems obvious that `execfile` has to open the file otherwise it can't possibly work. Is that what you're asking? Or something else? – pvg Jun 06 '17 at 09:05
  • Does it close file after execution process? – LRDPRDX Jun 06 '17 at 09:19
  • Is there some reason you think it wouldn't? You can trivially `strace` it to check. – pvg Jun 06 '17 at 09:26

0 Answers0