`flume::Sender<T>` stops to send messages to `flume::Receiver<T>` when passed through `.await` point
Closed this issue · 2 comments
vikulikov commented
I did not construct minimual breaking example but the code I have looks similar to this one:
fn main() {
let rt = tokio::runtime::Builder::new_current_thread()
.thread_name("async")
.enable_all()
.build()
.unwrap();
rt.block_on(async {
let (flume_tx, flume_rx) = flume::unbounded::<String>();
let task_join_handle = tokio::spawn(async move {
loop {
let msg = flume_rx.recv_async().await.unwrap();
println!("{msg}");
}
});
let tokio_oneshot_receiver = ...; // receiving msg from another tokio task
let timeout_rcv = tokio::time::timeout(tokio::time::Duration::from_secs(20), tokio_oneshot_receiver);
flume_tx.send(String::from("msg1")).unwrap(); // flume_rx receives `msg1`
let _oneshot_msg = timeout_rcv.await; // got message successfully
flume_tx.send(String::from("msg2")).unwrap(); // flume_rx receives nothing
task_join_handle.await;
});
}
vikulikov commented
Never mind. I just was blocking the single threaded runtime in another place
zesterer commented
Ah, good to hear. I love it when issues get resolved without intervention! 😀