Make reading garbage more robust
This commit is contained in:
parent
9e317971b4
commit
e8437fd435
@ -518,9 +518,13 @@ def drain_potential_tty_garbage(p: 'subprocess.Popen[bytes]', data_request: str)
|
|||||||
# screen
|
# screen
|
||||||
termios.tcflush(tty.fileno(), termios.TCIFLUSH)
|
termios.tcflush(tty.fileno(), termios.TCIFLUSH)
|
||||||
data = b''
|
data = b''
|
||||||
start = time.monotonic()
|
give_up_at = time.monotonic() + 1
|
||||||
while time.monotonic() - start < 1 and select([tty], [], [], 0.075)[0]:
|
tty_fd = tty.fileno()
|
||||||
q = os.read(tty.fileno(), io.DEFAULT_BUFFER_SIZE)
|
while time.monotonic() < give_up_at:
|
||||||
|
rd, wr, err = select([tty_fd], [], [tty_fd], max(0, give_up_at - time.monotonic()))
|
||||||
|
if err or not rd:
|
||||||
|
break
|
||||||
|
q = os.read(tty_fd, io.DEFAULT_BUFFER_SIZE)
|
||||||
if not q:
|
if not q:
|
||||||
break
|
break
|
||||||
data += q
|
data += q
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user