MCPcopy Create free account
hub / github.com/apache/paimon-rust / await_with_runtime

Function await_with_runtime

crates/integrations/datafusion/src/runtime.rs:48–57  ·  view source on GitHub ↗

These helpers work around DataFusion FFI callbacks that may run without an entered Tokio runtime. See https://github.com/apache/datafusion/issues/16312. A global OnceLock avoids creating a new runtime on every call; if DataFusion fixes runtime propagation end-to-end, we should be able to remove these manual fallback runtimes.

(future: F)

Source from the content-addressed store, hash-verified

46// if DataFusion fixes runtime propagation end-to-end, we should be able to
47// remove these manual fallback runtimes.
48pub(crate) async fn await_with_runtime<F>(future: F) -> F::Output
49where
50 F: Future,
51{
52 if Handle::try_current().is_ok() {
53 future.await
54 } else {
55 global_runtime().block_on(future)
56 }
57}
58
59// The blocking variant is for synchronous DataFusion FFI callbacks such as
60// CatalogProvider::schema(), where we cannot `.await` directly.

Callers 14

tableMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85
scanMethod · 0.85

Calls 1

global_runtimeFunction · 0.85

Tested by

no test coverage detected