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

Futures polling can block #30

Open
idletea opened this issue Jan 12, 2019 · 0 comments
Open

Futures polling can block #30

idletea opened this issue Jan 12, 2019 · 0 comments

Comments

@idletea
Copy link

idletea commented Jan 12, 2019

An example test which will fail (or more accurately: block infinitely)

#[test]
fn futures_do_not_block() {
    let (tx, rx) = multiqueue::broadcast_fut_queue::<i32>(16);
    let mut rt = tokio::runtime::Runtime::new().unwrap();
    rt.block_on(
        rx
        .for_each(|_| {
            futures::future::ok(())
        })
        .into_future()
        .timeout(Duration::from_millis(100))
        .then(|result| {
            match result {
                Ok(_) => Err("this never has a change to even come up - the above blocks forever"),
                Err(_) => Ok("timed out as expected"),
            }
        })
    ).unwrap();
}

This test will hang because this loop has a case in which it'll keep spinning on the recv attempt and never returns control to the event loop.

As such the timeout never has a chance to be considered reached and the future never resolves even with the timeout on it.

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

No branches or pull requests

1 participant