From 85f3ca3a6b4f8d03907fff0174369fa211c2edcc Mon Sep 17 00:00:00 2001 From: Michael-J-Ward Date: Fri, 4 Oct 2024 13:09:11 -0500 Subject: [PATCH] remove superflous Arc from get_tokio_runtime --- src/utils.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index e2ff3e29c..0cf7152ba 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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 { - static RUNTIME: OnceLock> = 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 = OnceLock::new(); + RUNTIME.get_or_init(|| { + let rt = TokioRuntime(tokio::runtime::Runtime::new().unwrap()); + rt + }) } /// Utility to collect rust futures with GIL released