make input more responsible, add timeout
This commit is contained in:
parent
4847b1c78b
commit
65055acb66
@ -78,11 +78,13 @@ class driver(screenDriver):
|
|||||||
self.env['screen']['autoIgnoreScreens'] = []
|
self.env['screen']['autoIgnoreScreens'] = []
|
||||||
self.env['general']['prevUser'] = getpass.getuser()
|
self.env['general']['prevUser'] = getpass.getuser()
|
||||||
self.env['general']['currUser'] = getpass.getuser()
|
self.env['general']['currUser'] = getpass.getuser()
|
||||||
def readAll(self,fd):
|
def readAll(self,fd, timeout = 9999999):
|
||||||
bytes = os.read(fd, 65536)
|
bytes = os.read(fd, 65536)
|
||||||
if bytes == b'':
|
if bytes == b'':
|
||||||
raise EOFError
|
raise EOFError
|
||||||
while screen_utils.hasMore(fd,0.0002):
|
starttime = time.time()
|
||||||
|
# respect timeout but wait a little bit of time to see if something more is here
|
||||||
|
while screen_utils.hasMore(fd,0.000001) and (time.time() - starttime) >= timeout:
|
||||||
data = os.read(fd, 65536)
|
data = os.read(fd, 65536)
|
||||||
if data == b'':
|
if data == b'':
|
||||||
raise EOFError
|
raise EOFError
|
||||||
@ -151,7 +153,7 @@ class driver(screenDriver):
|
|||||||
if debug:
|
if debug:
|
||||||
print('pre p_out')
|
print('pre p_out')
|
||||||
try:
|
try:
|
||||||
msgBytes = self.readAll(self.p_out.fileno())
|
msgBytes = self.readAll(self.p_out.fileno(), timeout=0.2)
|
||||||
except (EOFError, OSError):
|
except (EOFError, OSError):
|
||||||
active.value = False
|
active.value = False
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user