mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
feat(python): use a current_thread executor
This commit is contained in:
parent
76e5320e6a
commit
a45db74722
1 changed files with 8 additions and 1 deletions
|
@ -22,7 +22,14 @@ use tokio::sync::{mpsc, Mutex};
|
||||||
fn tokio() -> &'static tokio::runtime::Runtime {
|
fn tokio() -> &'static tokio::runtime::Runtime {
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
static RT: OnceLock<tokio::runtime::Runtime> = OnceLock::new();
|
static RT: OnceLock<tokio::runtime::Runtime> = 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
|
// workaround to allow the GIL to be released across awaits, waiting on
|
||||||
|
|
Loading…
Reference in a new issue