This function takes a function that returns a future instead of taking just a future because a task might return an unsendable future but what we can do is making a function returning that future which is sendable itself
(task: T)
| 414 | // a task might return an unsendable future but what we can do is making a function returning that |
| 415 | // future which is sendable itself |
| 416 | pub fn execute_async_task<T, F, O>(task: T) -> O |
| 417 | where |
| 418 | T: FnOnce() -> F + Send + 'static, |
| 419 | F: Future<Output = O> + 'static, |
| 420 | O: Send + 'static, |
| 421 | { |
| 422 | Python::attach(|py| py.detach(move || get_runtime().block_on(task()))) |
| 423 | } |
| 424 | |
| 425 | static RUNTIME: OnceLock<Runtime> = OnceLock::new(); |
| 426 |
no test coverage detected