Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jwzl
Copy link

@jwzl jwzl commented Jul 8, 2025

…ndows

  • Properly handle None for self._write_timeout by using win32.INFINITE.
  • Use WaitForSingleObject to wait with timeout before calling GetOverlappedResult.
  • If timeout occurs (WAIT_TIMEOUT), cancel the pending write using CancelIoEx.
  • Avoid blocking indefinitely on GetOverlappedResult by passing wait=False.
  • Raise SerialTimeoutException if the write is incomplete or canceled.

This prevents the serial write from hanging indefinitely when the device becomes unresponsive.

…ndows

- Properly handle `None` for `self._write_timeout` by using `win32.INFINITE`.
- Use `WaitForSingleObject` to wait with timeout before calling `GetOverlappedResult`.
- If timeout occurs (`WAIT_TIMEOUT`), cancel the pending write using `CancelIoEx`.
- Avoid blocking indefinitely on `GetOverlappedResult` by passing `wait=False`.
- Raise `SerialTimeoutException` if the write is incomplete or canceled.

This prevents the serial write from hanging indefinitely when the device becomes unresponsive.
@lbrendel-signum
Copy link

@jwzl would a similar but different update need to be done for read? I have recently been facing GetOverlappedResult blocking on me and have experienced it with read before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants