mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
fix: run blocking function on a different task (#2570)
This avoids freezing the current task if the fn blocks indefinitely
This commit is contained in:
parent
6906a2f75e
commit
fb6d57a281
1 changed files with 4 additions and 3 deletions
|
@ -793,9 +793,10 @@ where
|
||||||
let result_buf = f()?;
|
let result_buf = f()?;
|
||||||
Ok(Op::Sync(result_buf))
|
Ok(Op::Sync(result_buf))
|
||||||
} else {
|
} else {
|
||||||
Ok(Op::Async(Box::new(tokio_util::poll_fn(move || {
|
Ok(Op::Async(Box::new(futures::sync::oneshot::spawn(
|
||||||
convert_blocking(f)
|
tokio_util::poll_fn(move || convert_blocking(f)),
|
||||||
}))))
|
&tokio_executor::DefaultExecutor::current(),
|
||||||
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue