Update ptyDriver.py
This commit is contained in:
parent
b87dccbd49
commit
7dfaa2dbeb
@ -77,21 +77,21 @@ class driver(screenDriver):
|
|||||||
self.env['general']['currUser'] = getpass.getuser()
|
self.env['general']['currUser'] = getpass.getuser()
|
||||||
def readAll(self,fd, timeout = 9999999, interruptFd = None, len = 4096):
|
def readAll(self,fd, timeout = 9999999, interruptFd = None, len = 4096):
|
||||||
bytes = b''
|
bytes = b''
|
||||||
starttime = time.time()
|
|
||||||
# respect timeout but wait a little bit of time to see if something more is here
|
|
||||||
fdList = [fd]
|
fdList = [fd]
|
||||||
if interruptFd:
|
if interruptFd:
|
||||||
fdList += [interruptFd]
|
fdList += [interruptFd]
|
||||||
|
starttime = time.time()
|
||||||
while True:
|
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
|
hasmore = fd in r
|
||||||
if not hasmore:
|
if not hasmore:
|
||||||
break
|
break
|
||||||
# exit on interrupt available
|
# exit on interrupt available
|
||||||
if interruptFd in r:
|
if interruptFd in r:
|
||||||
break
|
break
|
||||||
if (time.time() - starttime) >= timeout:
|
|
||||||
break
|
|
||||||
data = os.read(fd, len)
|
data = os.read(fd, len)
|
||||||
if data == b'':
|
if data == b'':
|
||||||
raise EOFError
|
raise EOFError
|
||||||
@ -160,7 +160,7 @@ class driver(screenDriver):
|
|||||||
# output
|
# output
|
||||||
if self.p_out in r:
|
if self.p_out in r:
|
||||||
try:
|
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):
|
except (EOFError, OSError):
|
||||||
active.value = False
|
active.value = False
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user