summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cao <jcao2462@gmail.com>2019-06-27 01:12:11 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-06-26 19:12:11 -0400
commitfb6d57a28172aeaaa5fdb31d5775e190bdfaa1c1 (patch)
tree7b6666d7a0255a537fcf22aeda680925d0f98bac
parent6906a2f75e428221f8b9bfa28b2c6821eb3ebe30 (diff)
fix: run blocking function on a different task (#2570)
This avoids freezing the current task if the fn blocks indefinitely
-rw-r--r--cli/ops.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/cli/ops.rs b/cli/ops.rs
index 56569c37a..bf4016366 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -793,9 +793,10 @@ where
let result_buf = f()?;
Ok(Op::Sync(result_buf))
} else {
- Ok(Op::Async(Box::new(tokio_util::poll_fn(move || {
- convert_blocking(f)
- }))))
+ Ok(Op::Async(Box::new(futures::sync::oneshot::spawn(
+ tokio_util::poll_fn(move || convert_blocking(f)),
+ &tokio_executor::DefaultExecutor::current(),
+ ))))
}
}