line = p.stdout.readline()
print("child stdout>", line)
m = pat.search(line.decode())
if m is not None:
break
else:
pytest.fail("no matching log line in process output")
port = int(m.group(1))
assert port > 0
After Change
with run_bokeh_serve(["--port", "0"]) as p:
flags = fcntl(p.stdout, F_GETFL)
fcntl(p.stdout, F_SETFL, flags | O_NONBLOCK)
sleep(2)
o = read(p.stdout.fileno(), 100*1024)
m = pat.search(o.decode())
if m is None:
pytest.fail("no matching log line in process output")