[Bug 222112] lang/python36 selectors.select() does not block on named pipes / mkfifo
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Sep 7 20:41:17 UTC 2017
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222112
--- Comment #2 from Jeff Kletsky <jeff+freebsd at wagsky.com> ---
@tobic code, for anyone that finds this through search:
After opening the FIFO for reading, open it again for writing to prevent your
program from ever seeing EOF at all (i.e. pretend there is always at least 1
writer). There is no need to use select() here; readline() will already block
and wait for new data.
Code:
import logging
def test():
command_pipe = 'commands-in'
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
logger.info(f"Opening command pipe: '{command_pipe}'")
with open(command_pipe, "r") as cp, open(command_pipe, "w"):
while True:
line = cp.readline()
logger.info(f"Read: '{line}'")
if __name__ == '__main__':
test()
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-python
mailing list