https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222112

--- Comment #2 from Jeff Kletsky <jeff+free...@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.
_______________________________________________
freebsd-python@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-python
To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"

Reply via email to