Skip to content

Commit

Permalink
fix: run blocking function on a different task (denoland#2570)
Browse files Browse the repository at this point in the history
This avoids freezing the current task if the fn blocks indefinitely
  • Loading branch information
jcao219 authored and ry committed Jun 26, 2019
1 parent 6906a2f commit fb6d57a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cli/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))))
}
}

Expand Down

0 comments on commit fb6d57a

Please sign in to comment.