0

How to block on last write until other program read the fifo ?

import os
fn='/tmp/fifo'
try:
    os.mkfifo(fn)
except FileExistsError as e:
    print(fn,e)
f=os.open(fn, os.O_SYNC | os.O_CREAT | os.O_RDWR)
os.write(f, r)  # how to block on there
print('write end!')
CS QGB
  • 297
  • 1
  • 3
  • 12
  • 1
    None of those open flags make sense for a fifo... see `man 7 pipe` – Shawn May 03 '21 at 05:10
  • 1
    Actually, I partially take that back. `man 7 fifo` says *Under Linux, opening a FIFO for read and write will succeed both in blocking and nonblocking mode. POSIX leaves this behavior undefined. This can be used to open a FIFO for writing while there are no readers available.* But `O_SYNC` and `O_CREAT` are still nonsense. – Shawn May 03 '21 at 05:18

1 Answers1

-1

Maybe u can create a fuction that waits until X condition change. Like this:

import time
def waitUntil(condition, output): #defines function
    wU = True
    while wU == True:
        if condition: #checks the condition
            output
            wU = False
        time.sleep(60) #waits 60s for preformance