Don't try launching a tokio runtime if we are already within one (#4699)

This commit is contained in:
Moritz Hedtke authored and GitHub committed 2025-10-03 18:31:56 -07:00
1 parent c709c415c9
commit 6456576a77
1 file changed
+9
+9
View File
@@ -115,6 +115,14 @@ pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, mut desktop_config:
pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) -> ! { pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) -> ! {
#[cfg(feature = "tokio_runtime")] #[cfg(feature = "tokio_runtime")]
{ {
if let std::result::Result::Ok(handle) = tokio::runtime::Handle::try_current() {
assert_ne!(
handle.runtime_flavor(),
tokio::runtime::RuntimeFlavor::CurrentThread,
"The tokio current-thread runtime does not work with dioxus event handling"
);
launch_virtual_dom_blocking(virtual_dom, desktop_config);
} else {
tokio::runtime::Builder::new_multi_thread() tokio::runtime::Builder::new_multi_thread()
.enable_all() .enable_all()
.build() .build()
@@ -125,6 +133,7 @@ pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) -> !
unreachable!("The desktop launch function will never exit") unreachable!("The desktop launch function will never exit")
} }
}
#[cfg(not(feature = "tokio_runtime"))] #[cfg(not(feature = "tokio_runtime"))]
{ {