You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thread 'tokio-runtime-worker' panicked at 'internal error: entered unreachable code', src/main.rs:5:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: JoinError::Panic(...)
I was thinking that since the async function had returned, the select would do something, and seeing no matched arms would proceed to the next iteration of the loop. Despite this being a potentially faulty mental model of how select! is supposed to work, the "entered unreachable code" bit seemed worthy of a bugrep.
This corrected code does not panic, but requires me to handle all intermediate values on the channel, which I just want to ignore.
#[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (_, mut rx) = tokio::sync::watch::channel("a");
let join_handle = tokio::spawn(async move {
loop {
tokio::select! {
o = rx.recv() => {
match o {
None => { return; }
_ => {}
}
}
}
}
});
join_handle.await?;
Ok(())
}
The text was updated successfully, but these errors were encountered:
Version
└── tokio v0.2.22
└── tokio-macros v0.2.5
Platform
macOS 10.15.5
Description
tokio panics when all select! arms have been disabled
I tried this code:
Result:
I was thinking that since the async function had returned, the select would do something, and seeing no matched arms would proceed to the next iteration of the loop. Despite this being a potentially faulty mental model of how select! is supposed to work, the "entered unreachable code" bit seemed worthy of a bugrep.
This corrected code does not panic, but requires me to handle all intermediate values on the channel, which I just want to ignore.
The text was updated successfully, but these errors were encountered: