I\'m trying to read from an open os.pipe()
to see if it\'s empty at the moment of the reading. The problem is that calling read()
causes the program to
You might try this.
import os, fcntl
fcntl.fcntl(thePipe, fcntl.F_SETFL, os.O_NONBLOCK)
With this thePipe.read()
should be non-blocking.
From pipe(7) man page:
If a process attempts to read from an empty pipe, then read(2) will block until data is available. (...) Non-blocking I/O is possible by using the fcntl(2)
F_SETFL
operation to enable theO_NONBLOCK
open file status flag.