Yield instead of sleep in component-async-tests#12567
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom Feb 11, 2026
Merged
Yield instead of sleep in component-async-tests#12567alexcrichton merged 2 commits intobytecodealliance:mainfrom
alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
Use cooperative yields instead of sleeps to make tests more deterministic and also avoid them unnecessarily taking up test parallelism by sleeping. Yielding should have the same effect in terms of testing by exercising behavior returning `Pending` in futures, so there's no expected loss in test coverage here.
dicej
approved these changes
Feb 11, 2026
| // that we'll resolve the future independently, with or without | ||
| // giving it more work to do. | ||
| util::sleep(Duration::from_millis(100)).await; | ||
| util::yield_times(100).await; |
Contributor
There was a problem hiding this comment.
Is the 100 here just an artifact from when we slept 100ms, or did we really need to yield 100 times (or at least more than 10 or so)?
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.
Use cooperative yields instead of sleeps to make tests more deterministic and also avoid them unnecessarily taking up test parallelism by sleeping. Yielding should have the same effect in terms of testing by exercising behavior returning
Pendingin futures, so there's no expected loss in test coverage here.