test: twister: add more exception protection
the ser.in_wait sometime meet issue like serial handler error. This is because the serial port is in reset status. add final protection to retry later error log: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "zephyr/scripts/pylib/twister/twisterlib/handlers.py", line 345, in monitor_serial if not ser.in_waiting: File "~/python3.10/site-packages/serial/serialposix.py", line 549, in in_waiting s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str) OSError: [Errno 9] Bad file descriptor Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
parent
02653e13cf
commit
70553a64a3
1 changed files with 10 additions and 3 deletions
|
@ -341,9 +341,16 @@ class DeviceHandler(Handler):
|
|||
ser.close()
|
||||
break
|
||||
|
||||
if not ser.in_waiting:
|
||||
# no incoming bytes are waiting to be read from the serial
|
||||
# input buffer, let other threads run
|
||||
try:
|
||||
if not ser.in_waiting:
|
||||
# no incoming bytes are waiting to be read from
|
||||
# the serial input buffer, let other threads run
|
||||
time.sleep(0.001)
|
||||
continue
|
||||
# maybe the serial port is still in reset
|
||||
# check status may cause error
|
||||
# wait for more time
|
||||
except OSError:
|
||||
time.sleep(0.001)
|
||||
continue
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue