-
-
Notifications
You must be signed in to change notification settings - Fork 164
Description
What crate(s) in this repo are involved in the problem?
Tokio-console and console-subscriber
What is the issue?
tokio-console has a mechanism to restart itself if it detects a new program has attached. For example: I'm running a.rs, and after that I decide to stop the process and run b.rs. Console will detect b.rs is a different process and will update the list of tasks to only show those of b.rs. However, not always does this detection work.
If a.rs and b.rs are using the #[tokio::main] macro to initialize the runtime, then detection works fine. However, if one is using #[tokio::main] macro, whereas the other is using tokio::runtime::Runtime::new() this detection does not take place. The result is tasks from a.rs gets mixed in with the ones from b.rs
How can the bug be reproduced?
As I described before, it can be reproduced with one program using the #[tokio::main] and the other using tokio::runtime::Runtime::new().
Steps:
- run
a.rs - run
tokio-console - stop
a.rs - run
b.rs - view console showing tasks from
a.rsandb.rs
Program using #[tokio::main] macro (a.rs)
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
console_subscriber::init();
let seconds = 6000;
let task = tokio::task::Builder::new()
.name("task1")
.spawn(wait(6000))
.unwrap();
let result = tokio::try_join! {
task,
};
result?;
Ok(())
}
async fn wait(seconds: u64) {
tokio::time::sleep(Duration::from_secs(seconds)).await;
}Program using tokio::runtime::Runtime::new() (b.rs)
use std::time::Duration;
fn main() {
console_subscriber::init();
let rt = tokio::runtime::Runtime::new()
.unwrap();
rt.block_on(async {
tokio::time::sleep(std::time::Duration::from_secs(6000)).await;
});
}Logs, error output, etc
No response
Versions
console-api v0.6.0
console-subscriber v0.2.0
Possible solution
I don't know
Additional context
Would you like to work on fixing this bug?
yes
