Skip to content

Commit

Permalink
remove superflous Arc from get_tokio_runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-J-Ward committed Oct 4, 2024
1 parent cafd59e commit 85f3ca3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ use crate::TokioRuntime;
use datafusion::logical_expr::Volatility;
use pyo3::prelude::*;
use std::future::Future;
use std::sync::{Arc, OnceLock};
use std::sync::OnceLock;
use tokio::runtime::Runtime;

/// Utility to get the Tokio Runtime from Python
pub(crate) fn get_tokio_runtime() -> Arc<TokioRuntime> {
static RUNTIME: OnceLock<Arc<TokioRuntime>> = OnceLock::new();
RUNTIME
.get_or_init(|| {
let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap());
Arc::new(rt)
})
.clone()
pub(crate) fn get_tokio_runtime() -> &'static TokioRuntime {
static RUNTIME: OnceLock<TokioRuntime> = OnceLock::new();
RUNTIME.get_or_init(|| {
let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap());
rt
})
}

/// Utility to collect rust futures with GIL released
Expand Down

0 comments on commit 85f3ca3

Please sign in to comment.