mirror of
https://github.com/clearml/wexpect-venv
synced 2025-01-31 02:46:59 +00:00
[FIX] raise EOF when child finished and all character has been read
This commit is contained in:
parent
6de82c8244
commit
b0f03ee7ae
12
wexpect.py
12
wexpect.py
@ -443,6 +443,7 @@ class spawn_windows ():
|
|||||||
self.signalstatus = None
|
self.signalstatus = None
|
||||||
self.status = None # status returned by os.waitpid
|
self.status = None # status returned by os.waitpid
|
||||||
self.flag_eof = False
|
self.flag_eof = False
|
||||||
|
self.flag_child_finished = False
|
||||||
self.pid = None
|
self.pid = None
|
||||||
self.child_fd = -1 # initially closed
|
self.child_fd = -1 # initially closed
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@ -739,8 +740,17 @@ class spawn_windows ():
|
|||||||
raise ValueError ('I/O operation on closed file in read_nonblocking().')
|
raise ValueError ('I/O operation on closed file in read_nonblocking().')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# The real child and it's console are two different process. The console dies 0.1 sec
|
||||||
|
# later to be able to read the child's last output (before EOF). So here we check
|
||||||
|
# isalive() (which checks the real child.) and try a last read on the console. To catch
|
||||||
|
# the last output.
|
||||||
|
# The flag_child_finished flag shows that this is the second trial, where we raise the EOF.
|
||||||
|
if self.flag_child_finished:
|
||||||
|
raise EOF('self.self.flag_child_finished')
|
||||||
|
if not self.isalive():
|
||||||
|
self.flag_child_finished = True
|
||||||
s = self.wtty.read_nonblocking(size)
|
s = self.wtty.read_nonblocking(size)
|
||||||
except:
|
except EOF:
|
||||||
self.flag_eof = True
|
self.flag_eof = True
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user