Nicer error message on I/O error with child over pty

This commit is contained in:
Kovid Goyal 2024-10-29 06:01:35 +05:30
parent 11b0522eb9
commit bbd2df7e4d
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -391,7 +391,12 @@ def process_input_from_child(self, timeout=10):
def wait_till(self, q, timeout=10, timeout_msg=None):
end_time = time.monotonic() + timeout
while not q() and time.monotonic() <= end_time:
self.process_input_from_child(timeout=end_time - time.monotonic())
try:
self.process_input_from_child(timeout=end_time - time.monotonic())
except OSError as e:
if not q():
raise Exception(f'Failed to read from pty with error: {e}. Screen contents: \n {repr(self.screen_contents())}') from e
return
if not q():
msg = 'The condition was not met'
if timeout_msg is not None: