Skip to content

Commit d2dbc25

Browse files
add #[inline] annotation to get_tokio_runtime
I also included a reference comment in case future users experience problems with using datafusion-python behind a forking app server l ike `gunicorn`.
1 parent 85f3ca3 commit d2dbc25

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ use std::sync::OnceLock;
2424
use tokio::runtime::Runtime;
2525

2626
/// Utility to get the Tokio Runtime from Python
27+
#[inline]
2728
pub(crate) fn get_tokio_runtime() -> &'static TokioRuntime {
29+
// NOTE: Other pyo3 python libraries have had issues with using tokio
30+
// behind a forking app-server like `gunicorn`
31+
// If we run into that problem, in the future we can look to `delta-rs`
32+
// which adds a check in that disallows calls from a forked process
33+
// https://github.com/delta-io/delta-rs/blob/87010461cfe01563d91a4b9cd6fa468e2ad5f283/python/src/utils.rs#L10-L31
2834
static RUNTIME: OnceLock<TokioRuntime> = OnceLock::new();
2935
RUNTIME.get_or_init(|| {
3036
let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap());

0 commit comments

Comments
 (0)