Dont read more data than needed in TTYIO
This commit is contained in:
parent
2aba3e249c
commit
6db1f8e3e3
@ -382,8 +382,7 @@ class TTYIO:
|
|||||||
for chunk in data:
|
for chunk in data:
|
||||||
write_all(self.tty_fd, chunk)
|
write_all(self.tty_fd, chunk)
|
||||||
|
|
||||||
def recv(self, more_needed, timeout):
|
def recv(self, more_needed, timeout, sz=1):
|
||||||
from io import DEFAULT_BUFFER_SIZE
|
|
||||||
import select
|
import select
|
||||||
fd = self.tty_fd
|
fd = self.tty_fd
|
||||||
start_time = monotonic()
|
start_time = monotonic()
|
||||||
@ -391,7 +390,7 @@ class TTYIO:
|
|||||||
rd = select.select([fd], [], [], max(0, timeout - (monotonic() - start_time)))[0]
|
rd = select.select([fd], [], [], max(0, timeout - (monotonic() - start_time)))[0]
|
||||||
if not rd:
|
if not rd:
|
||||||
break
|
break
|
||||||
data = os.read(fd, DEFAULT_BUFFER_SIZE)
|
data = os.read(fd, sz)
|
||||||
if not data:
|
if not data:
|
||||||
break # eof
|
break # eof
|
||||||
if not more_needed(data):
|
if not more_needed(data):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user