diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs index e8410120116f..83bcafe7d834 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs @@ -1,5 +1,4 @@ use super::*; -use futures::lock::Mutex; use once_cell::sync::Lazy; use serde::de::DeserializeOwned; use std::{ @@ -7,7 +6,7 @@ use std::{ io::Write as _, sync::{atomic::Ordering, Arc}, }; -use tokio::sync::{mpsc, oneshot}; +use tokio::sync::{mpsc, oneshot, RwLock}; type Result = std::result::Result>; @@ -103,23 +102,23 @@ impl ExecutorProcess { /// asynchronous code are translated to an abort trap by wasm-bindgen, which kills the node process. #[derive(Clone)] pub(crate) struct RestartableExecutorProcess { - process: Arc>, + process: Arc>, } impl RestartableExecutorProcess { fn new() -> Self { Self { - process: Arc::new(Mutex::new(ExecutorProcess::spawn())), + process: Arc::new(RwLock::new(ExecutorProcess::spawn())), } } async fn restart(&self) { - let mut process = self.process.lock().await; - _ = std::mem::replace(&mut *process, ExecutorProcess::spawn()); + let mut process = self.process.write().await; + *process = ExecutorProcess::spawn(); } pub(crate) async fn request(&self, method: &str, params: serde_json::Value) -> Result { - let p = self.process.lock().await; + let p = self.process.read().await; p.request(method, params).await } }