From e89c9f5855ae4e4a576df9a1676a9ff7fb7cc41d Mon Sep 17 00:00:00 2001 From: Colin Ho Date: Tue, 26 Nov 2024 21:57:37 -0800 Subject: [PATCH] [CHORE] Explain block_on function in common-runtime (#3442) Addresses: https://github.com/Eventual-Inc/Daft/issues/3435 --------- Co-authored-by: Colin Ho --- src/common/runtime/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/runtime/src/lib.rs b/src/common/runtime/src/lib.rs index 54e2555e61..2c8fc6acdd 100644 --- a/src/common/runtime/src/lib.rs +++ b/src/common/runtime/src/lib.rs @@ -100,7 +100,12 @@ impl Runtime { /// Spawns a task on the runtime and blocks the current thread until the task is completed. /// Similar to tokio's Runtime::block_on but requires static lifetime + Send - /// You should use this when you are spawning IO tasks from an Expression Evaluator or in the Executor + /// You should use this when you need to run an async task in a synchronous function, but you are already in a tokio runtime. + /// + /// For example, URL download is an async function, but it is called from a synchronous function in a tokio runtime, + /// i.e. calling the Expression Evaluator from the Native Executor. + /// + /// In the future, we should refactor the code to be fully async, but for now, this is a workaround. pub fn block_on(&self, future: F) -> DaftResult where F: Future + Send + 'static,