Skip to content

Commit 85f3ca3

Browse files
remove superflous Arc from get_tokio_runtime
1 parent cafd59e commit 85f3ca3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/utils.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ use crate::TokioRuntime;
2020
use datafusion::logical_expr::Volatility;
2121
use pyo3::prelude::*;
2222
use std::future::Future;
23-
use std::sync::{Arc, OnceLock};
23+
use std::sync::OnceLock;
2424
use tokio::runtime::Runtime;
2525

2626
/// Utility to get the Tokio Runtime from Python
27-
pub(crate) fn get_tokio_runtime() -> Arc<TokioRuntime> {
28-
static RUNTIME: OnceLock<Arc<TokioRuntime>> = OnceLock::new();
29-
RUNTIME
30-
.get_or_init(|| {
31-
let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap());
32-
Arc::new(rt)
33-
})
34-
.clone()
27+
pub(crate) fn get_tokio_runtime() -> &'static TokioRuntime {
28+
static RUNTIME: OnceLock<TokioRuntime> = OnceLock::new();
29+
RUNTIME.get_or_init(|| {
30+
let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap());
31+
rt
32+
})
3533
}
3634

3735
/// Utility to collect rust futures with GIL released

0 commit comments

Comments
 (0)