Skip to content

Commit

Permalink
Merge remote-tracking branch 'mine/fix-crash-blocking-inside-tokio' i…
Browse files Browse the repository at this point in the history
…nto fix-crash-blocking-inside-tokio

Fix formatting
  • Loading branch information
ramon-garcia committed Apr 6, 2024
2 parents 7480c4d + 5aa6a40 commit 92f99ed
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/blocking/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ pub(crate) fn timeout<F, I, E>(fut: F, timeout: Option<Duration>) -> Result<I, W
where
F: Future<Output = Result<I, E>>,
{

let try_tokio_handle = tokio::runtime::Handle::try_current();
if let Ok(tokio_handle) = try_tokio_handle {
return tokio::task::block_in_place(||
return tokio::task::block_in_place(|| {
tokio_handle.block_on(async {
if let Some(actual_timeout) = timeout {
tokio::select! {
Expand All @@ -24,7 +23,7 @@ where
fut.await.map_err(|e| Waited::Inner(e))
}
})
)
});
}

let deadline = timeout.map(|d| {
Expand Down Expand Up @@ -80,4 +79,3 @@ impl futures_util::task::ArcWake for ThreadWaker {
arc_self.0.unpark();
}
}

0 comments on commit 92f99ed

Please sign in to comment.