Skip to content

Commit fa5b029

Browse files
committed
Add async { ..await } in remaining places
Since it seems to make a difference to `tokio` (see https://docs.rs/tokio/latest/tokio/time/fn.timeout.html#panics) we make sure the futures are always put in an `async` closure.
1 parent 141f186 commit fa5b029

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Runtime {
6767
{
6868
let mut background_tasks = self.background_tasks.lock().unwrap();
6969
let runtime_handle = self.handle();
70-
background_tasks.spawn_on(future, runtime_handle);
70+
background_tasks.spawn_on(async { future.await }, runtime_handle);
7171
}
7272

7373
pub fn spawn_cancellable_background_task<F>(&self, future: F)
@@ -76,7 +76,7 @@ impl Runtime {
7676
{
7777
let mut cancellable_background_tasks = self.cancellable_background_tasks.lock().unwrap();
7878
let runtime_handle = self.handle();
79-
cancellable_background_tasks.spawn_on(future, runtime_handle);
79+
cancellable_background_tasks.spawn_on(async { future.await }, runtime_handle);
8080
}
8181

8282
pub fn spawn_background_processor_task<F>(&self, future: F)
@@ -107,7 +107,7 @@ impl Runtime {
107107
// to detect the outer context here, and otherwise use whatever was set during
108108
// initialization.
109109
let handle = tokio::runtime::Handle::try_current().unwrap_or(self.handle().clone());
110-
tokio::task::block_in_place(move || handle.block_on(future))
110+
tokio::task::block_in_place(move || handle.block_on(async { future.await }))
111111
}
112112

113113
pub fn abort_cancellable_background_tasks(&self) {

0 commit comments

Comments
 (0)