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

no progress with concurrent streams and tokio #183

Closed
yanns opened this issue Apr 24, 2024 · 1 comment
Closed

no progress with concurrent streams and tokio #183

yanns opened this issue Apr 24, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@yanns
Copy link

yanns commented Apr 24, 2024

When using the following code:

async fn say_hello(who: &str) -> Vec<String> {
    let input: Vec<_> = (1..=5).collect();
    let results = input
        .into_co_stream()
        .map(|i| hello(i, who))
        .collect()
        .await;

    results
}

async fn hello(i: i32, who: &str) -> String {
    println!("Job {i} started");
    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
    let result = format!("Task {i}: Hello {who}");
    println!("Job {i} finished with result {result}");
    result
}

The program outputs:

Starting jobs...
Job 1 started
Job 2 started
Job 3 started
Job 4 started
Job 5 started
Job 5 finished with result Task 5: Hello world

and does not make any progress afterwards

@yoshuawuyts
Copy link
Owner

yoshuawuyts commented Apr 24, 2024

Thank you for reporting this! This seems like a likely duplicate of #182. I'm going to close this in favor of that.

@yoshuawuyts yoshuawuyts added the duplicate This issue or pull request already exists label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants