Skip to content
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

Fix missing wake() in PendingOnce #2799

Closed
wants to merge 1 commit into from
Closed

Fix missing wake() in PendingOnce #2799

wants to merge 1 commit into from

Conversation

nickd-airo
Copy link

PendingOnce should wake() before returning Pending, otherwise executors may not poll() again.

Without this change, the following code blocks forever:

#[test]
fn test_block_on() {
    async fn test_fut() {
        futures::pending!();
    }
    futures::executor::block_on(test_fut())
}

PendingOnce should wake() before returning Pending,
otherwise executors may not poll() again.
@taiki-e
Copy link
Member

taiki-e commented Nov 15, 2023

The current one is the correct behavior. Your change makes the executor immediately re-poll the future, which is not the intended behavior of this macro. See also docs.

Similarly, when using this macro, it must be ensured that wake is called somewhere when further progress can be made.

So I'm going to close this, but thanks anyway for the PR.

@taiki-e taiki-e closed this Nov 15, 2023
@nickd-airo
Copy link
Author

Sorry about that, I didn't read the documentation properly. Thanks for clarifying!

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