Skip to content

Commit 7bd848a

Browse files
authored
Call reducers on the blocking pool. (#2737)
1 parent 3d1a91c commit 7bd848a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

crates/core/src/host/module_host.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,13 @@ impl ModuleHost {
592592
// compiler that `dyn ModuleInstance` is unwind safe.
593593
// If a reducer call panics, we **must** ensure to call `self.on_panic`
594594
// so that the module is discarded by the host controller.
595-
let result = tokio::spawn(async move { f(&mut *inst) }).await.unwrap_or_else(|e| {
596-
log::warn!("reducer {reducer} panicked");
597-
(self.on_panic)();
598-
std::panic::resume_unwind(e.into_panic());
599-
});
595+
let result = tokio::task::spawn_blocking(move || f(&mut *inst))
596+
.await
597+
.unwrap_or_else(|e| {
598+
log::warn!("reducer {reducer} panicked");
599+
(self.on_panic)();
600+
std::panic::resume_unwind(e.into_panic());
601+
});
600602
Ok(result)
601603
}
602604

0 commit comments

Comments
 (0)