Date: Thu, 07 Sep 2017 20:41:16 +0000 From: bugzilla-noreply@freebsd.org To: python@FreeBSD.org Subject: [Bug 222112] lang/python36 selectors.select() does not block on named pipes / mkfifo Message-ID: <bug-222112-21822-r2Q66O8TIH@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-222112-21822@https.bugs.freebsd.org/bugzilla/> References: <bug-222112-21822@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222112 --- Comment #2 from Jeff Kletsky <jeff+freebsd@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.help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-222112-21822-r2Q66O8TIH>
