Improve coroutine timeout handling#295
Merged
Merged
Conversation
This commit...
1. adds class-level `timeout_ms` attribute to customize runtime
of asyncio coroutines.
2. uses `timeout_ms` argument from test_... coroutines to cutomize
test case runtime.
example:
async def test_anything(self, timeout_ms=10000):
...
3. raises TimeoutError within context of currently awaited asynchronous
coroutine to ensure valuable tracebacks being printed.
rwols
reviewed
Jun 7, 2026
| yield {"condition": await_future, "timeout": timeout_ms} | ||
| except TimeoutError: | ||
| msg = f"Task not completed within {timeout_ms / 1000:.2f} seconds." | ||
| coro.throw(TimeoutError, msg) |
Contributor
There was a problem hiding this comment.
I didn’t know this .throw was possible. Very cool!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #294
This PR...
adds class-level
timeout_msattribute to customize runtime of asyncio coroutines.Example:
uses
timeout_msargument from test_... coroutines to cutomize test case runtime.Example:
raises TimeoutError within context of currently awaited asynchronous coroutine to ensure valuable tracebacks being printed.
Example: