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 37d3356
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ 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();
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());
Arc::new(rt)
rt
})
.clone()
}

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

0 comments on commit 37d3356

Please sign in to comment.