From 7dfaa2dbebfbd383a5ea17465b6d58ed22baddd5 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Wed, 30 May 2018 13:26:25 +0200 Subject: [PATCH] Update ptyDriver.py --- src/fenrirscreenreader/screenDriver/ptyDriver.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fenrirscreenreader/screenDriver/ptyDriver.py b/src/fenrirscreenreader/screenDriver/ptyDriver.py index 5091aa1e..a9f44dc4 100644 --- a/src/fenrirscreenreader/screenDriver/ptyDriver.py +++ b/src/fenrirscreenreader/screenDriver/ptyDriver.py @@ -77,21 +77,21 @@ class driver(screenDriver): self.env['general']['currUser'] = getpass.getuser() def readAll(self,fd, timeout = 9999999, interruptFd = None, len = 4096): bytes = b'' - starttime = time.time() - # respect timeout but wait a little bit of time to see if something more is here fdList = [fd] if interruptFd: fdList += [interruptFd] + starttime = time.time() while True: - r = screen_utils.hasMoreWhat(fdList,0.1): + # respect timeout but wait a little bit of time to see if something more is here + if (time.time() - starttime) >= timeout: + break + r = screen_utils.hasMoreWhat(fdList,0.05): hasmore = fd in r if not hasmore: break # exit on interrupt available if interruptFd in r: break - if (time.time() - starttime) >= timeout: - break data = os.read(fd, len) if data == b'': raise EOFError @@ -160,7 +160,7 @@ class driver(screenDriver): # output if self.p_out in r: try: - msgBytes = self.readAll(self.p_out.fileno(), timeout=0.5, interruptFd=sys.stdin) + msgBytes = self.readAll(self.p_out.fileno(), timeout=1, interruptFd=sys.stdin.fileno()) except (EOFError, OSError): active.value = False break