Skip to content

Commit

Permalink
Merge pull request #1579 from evshary/clear_panic_for_tls
Browse files Browse the repository at this point in the history
Provide a clearer panic log while missing TLS
  • Loading branch information
Mallets authored Nov 7, 2024
2 parents 840ee73 + 7373cab commit 03b2f7a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions commons/zenoh-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,16 @@ impl ZRuntime {
where
F: Future<Output = R>,
{
if let Ok(handle) = Handle::try_current() {
if handle.runtime_flavor() == RuntimeFlavor::CurrentThread {
panic!("Zenoh runtime doesn't support Tokio's current thread scheduler. Please use multi thread scheduler instead, e.g. a multi thread scheduler with one worker thread: `#[tokio::main(flavor = \"multi_thread\", worker_threads = 1)]`");
match Handle::try_current() {
Ok(handle) => {
if handle.runtime_flavor() == RuntimeFlavor::CurrentThread {
panic!("Zenoh runtime doesn't support Tokio's current thread scheduler. Please use multi thread scheduler instead, e.g. a multi thread scheduler with one worker thread: `#[tokio::main(flavor = \"multi_thread\", worker_threads = 1)]`");
}
}
Err(e) => {
if e.is_thread_local_destroyed() {
panic!("The Thread Local Storage inside Tokio is destroyed. This might happen when Zenoh API is called at process exit, e.g. in the atexit handler. Calling the Zenoh API at process exit is not supported and should be avoided.");
}
}
}
tokio::task::block_in_place(move || self.block_on(f))
Expand Down

0 comments on commit 03b2f7a

Please sign in to comment.