Set VMIN to 1 as without it poll() returns immediately even when no data is available to read on macOS
This commit is contained in:
parent
65ed9c759c
commit
c094ebce07
@ -275,7 +275,10 @@ class Loop:
|
|||||||
handler.write_buf[self.iov_limit - 1] = b''.join(handler.write_buf[self.iov_limit - 1:])
|
handler.write_buf[self.iov_limit - 1] = b''.join(handler.write_buf[self.iov_limit - 1:])
|
||||||
del handler.write_buf[self.iov_limit:]
|
del handler.write_buf[self.iov_limit:]
|
||||||
sizes = tuple(map(len, handler.write_buf))
|
sizes = tuple(map(len, handler.write_buf))
|
||||||
written = os.writev(fd, handler.write_buf)
|
try:
|
||||||
|
written = os.writev(fd, handler.write_buf)
|
||||||
|
except BlockingIOError:
|
||||||
|
return
|
||||||
if not written:
|
if not written:
|
||||||
raise EOFError('The output stream is closed')
|
raise EOFError('The output stream is closed')
|
||||||
if written >= sum(sizes):
|
if written >= sum(sizes):
|
||||||
|
|||||||
@ -108,7 +108,7 @@ static inline bool
|
|||||||
put_tty_in_raw_mode(int fd, const struct termios* termios_p) {
|
put_tty_in_raw_mode(int fd, const struct termios* termios_p) {
|
||||||
struct termios raw_termios = *termios_p;
|
struct termios raw_termios = *termios_p;
|
||||||
cfmakeraw(&raw_termios);
|
cfmakeraw(&raw_termios);
|
||||||
raw_termios.c_cc[VMIN] = 0; raw_termios.c_cc[VTIME] = 0;
|
raw_termios.c_cc[VMIN] = 1; raw_termios.c_cc[VTIME] = 0;
|
||||||
if (tcsetattr(fd, TCSAFLUSH, &raw_termios) != 0) { PyErr_SetFromErrno(PyExc_OSError); return false; }
|
if (tcsetattr(fd, TCSAFLUSH, &raw_termios) != 0) { PyErr_SetFromErrno(PyExc_OSError); return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user