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

Unexpected behavior when using tokio runtime #2

Open
saintazunya opened this issue Aug 15, 2022 · 2 comments
Open

Unexpected behavior when using tokio runtime #2

saintazunya opened this issue Aug 15, 2022 · 2 comments

Comments

@saintazunya
Copy link

Hi,

Thanks for creating this amazing project. It saved me a lot of boiler plates to run async tasks in parallel.
During my useage of this lib, I found that when using tokio as runtime, but not enabling the feature runtime-tokio will produce unexpected behaviors in programs.

Observed behavior:

use futures::prelude::*;
use par_stream::prelude::*;

let doubled: Vec<_> = stream::iter(0..1000)
    // doubles the values in parallel
    .par_then(None, move |value| async move { value * 2 })
    // the collected values will be ordered
    .collect()
    .await;
let expect: Vec<_> = (0..1000).map(|value| value * 2).collect();
assert_eq!(doubled, expect);

assert failed because the variable doubled is an empty Vector.

Expected behavior:

panic during compilation.

Thanks for supporting!

@cryptoquick
Copy link

I've noticed I've run into this kind of issue when I forget to add the tokio runtime feature in Cargo.toml, like so:
par-stream = { version = "0.10.2", features = ["runtime-tokio"] }
Without a runtime, it just passes through, doing nothing. I'm not sure if this is desirable, tbh, but now I know :)

@axos88
Copy link

axos88 commented Oct 31, 2023

Stumbled upon this as well. Seems like the stream is immediately closed, which is totally unexpected.

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

3 participants