Skip to content

Commit

Permalink
Handle poll-related errors, too
Browse files Browse the repository at this point in the history
posixpoll doesn't do this, but it seems like a sensible thing to do...

Relates to: #457
  • Loading branch information
canton7 committed Dec 14, 2023
1 parent 0f96261 commit ed31d4f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ def write(self, data: Any) -> int:
raise SerialTimeoutException("Write timeout")

result = _PollResult.TIMEOUT # In case poll returns an empty list
for fd, _event in poll.poll(None if timeout.is_infinite else (timeout.time_left() * 1000)):
for fd, event in poll.poll(None if timeout.is_infinite else (timeout.time_left() * 1000)):
if fd == self.pipe_abort_write_r:
os.read(self.pipe_abort_read_r, 1000)
result = _PollResult.ABORT
break
if event & (select.POLLERR | select.POLLHUP | select.POLLNVAL):
raise SerialException("device reports error (poll)")
result = _PollResult.READY

if result == _PollResult.TIMEOUT:
Expand Down

0 comments on commit ed31d4f

Please sign in to comment.