From fb6d57a28172aeaaa5fdb31d5775e190bdfaa1c1 Mon Sep 17 00:00:00 2001 From: Jimmy Cao Date: Thu, 27 Jun 2019 01:12:11 +0200 Subject: fix: run blocking function on a different task (#2570) This avoids freezing the current task if the fn blocks indefinitely --- cli/ops.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cli/ops.rs') 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(), + )))) } } -- cgit v1.2.3