From a45db747224baee0ff963ea619f97bc8e559e358 Mon Sep 17 00:00:00 2001 From: cschen Date: Sun, 18 Aug 2024 19:06:07 +0200 Subject: [PATCH] feat(python): use a current_thread executor --- src/ffi/python/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ffi/python/mod.rs b/src/ffi/python/mod.rs index 5ec9c38..ff454fd 100644 --- a/src/ffi/python/mod.rs +++ b/src/ffi/python/mod.rs @@ -22,7 +22,14 @@ use tokio::sync::{mpsc, Mutex}; fn tokio() -> &'static tokio::runtime::Runtime { use std::sync::OnceLock; static RT: OnceLock = OnceLock::new(); - RT.get_or_init(|| tokio::runtime::Runtime::new().unwrap()) + RT.get_or_init(|| { + tokio::runtime::Builder::new_current_thread() + .enable_all() + .on_thread_start(|| tracing::info!("tokio thread started.")) + .on_thread_stop(|| tracing::info!("tokio thread stopped.")) + .build() + .unwrap() + }) } // workaround to allow the GIL to be released across awaits, waiting on