-
Notifications
You must be signed in to change notification settings - Fork 182
todo: handle timeout #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
todo: handle timeout #752
Conversation
@seetadev Can you please give me pointers on this PR and how to write it's tests |
@Minimega12121 : Definitely, sharing a discussion page with further details soon. |
@Minimega12121 : HI Archit. Please check #774 . Happy to share pointers on pytest-trio-based test suite that covers the described test cases. Please also review and share feedback, thoughts on #637 . This PR indeed brings an important change. |
Please review the tests added @seetadev This PR adds two unit tests to validate the improved error handling and timeout logic in the
|
@Minimega12121 : Excellent work, Archit. Appreciate your efforts and initiative. This looks ready for final review + merge. Congratulations and keep up the great progress :) |
What was wrong?
Issue #
The original
send_message
call during stream close lacked proper timeout and error handling. This could result in the coroutine hanging indefinitely or raising unhandled exceptions when the underlying connection was unavailable or slow to respond. Additionally, there were TODO comments indicating incomplete error handling logic.How was it fixed?
Wrapped the
send_message
call with atrio.fail_after(5)
block to enforce a 5-second timeout during stream closure.Added exception handling for:
trio.TooSlowError
: Raises aTimeoutError
to indicate that stream close took too long.MuxedConnUnavailable
: Raises aRuntimeError
only if themuxed_conn
is not shutting down, preventing silent failures.These changes ensure proper cleanup logic, avoid indefinite blocking, and improve robustness by making failure modes explicit.
Please take a look @seetadev