lock start things

This commit is contained in:
Paul R. Tagliamonte
2025-03-13 14:58:24 -04:00
parent ec537cd8dc
commit b085af139b
3 changed files with 15 additions and 12 deletions

View File

@ -797,7 +797,7 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr
let ctx = crate::ExecutorContext {
engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())),
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
stdlib: std::sync::Arc::new(tokio::sync::RwLock::new(crate::std::StdLib::new())),
settings: Default::default(),
context_type: crate::execution::ContextType::Mock,
};

View File

@ -1188,7 +1188,7 @@ impl Node<CallExpressionKw> {
ctx.clone(),
exec_state.mod_local.pipe_value.clone().map(|v| Arg::new(v, callsite)),
);
match ctx.stdlib.get_either(fn_name) {
match ctx.stdlib.read().await.get_either(fn_name) {
FunctionKind::Core(func) => {
if func.deprecated() {
exec_state.warn(CompilationError::err(
@ -1312,7 +1312,7 @@ impl Node<CallExpression> {
}
let fn_args = fn_args; // remove mutability
match ctx.stdlib.get_either(fn_name) {
match ctx.stdlib.read().await.get_either(fn_name) {
FunctionKind::Core(func) => {
if func.deprecated() {
exec_state.warn(CompilationError::err(
@ -2024,7 +2024,7 @@ mod test {
parsing::ast::types::{DefaultParamVal, Identifier, Parameter},
};
use std::sync::Arc;
use tokio::task::JoinSet;
use tokio::{sync::RwLock, task::JoinSet};
#[test]
fn test_assign_args_to_params() {
@ -2274,12 +2274,14 @@ import 'a.kcl'
.unwrap(),
)),
fs: Arc::new(crate::fs::FileManager::new()),
stdlib: Arc::new(crate::std::StdLib::new()),
stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())),
settings: Default::default(),
context_type: ContextType::Mock,
};
let mut exec_state = ExecState::new(&exec_ctxt.settings);
eprintln!("{:?}", exec_ctxt);
eprintln!("{:?}", universe);
for modules in crate::walk::import_graph(&universe).unwrap().into_iter() {
eprintln!("Spawning {:?}", modules);

View File

@ -26,6 +26,7 @@ pub use memory::EnvironmentRef;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub use state::{ExecState, IdGenerator, MetaSettings};
use tokio::sync::RwLock;
use crate::{
engine::EngineManager,
@ -215,7 +216,7 @@ pub enum ContextType {
pub struct ExecutorContext {
pub engine: Arc<Box<dyn EngineManager>>,
pub fs: Arc<FileManager>,
pub stdlib: Arc<StdLib>,
pub stdlib: Arc<RwLock<StdLib>>,
pub settings: ExecutorSettings,
pub context_type: ContextType,
}
@ -360,7 +361,7 @@ impl ExecutorContext {
Ok(Self {
engine,
fs: Arc::new(FileManager::new()),
stdlib: Arc::new(StdLib::new()),
stdlib: Arc::new(RwLock::new(StdLib::new())),
settings,
context_type: ContextType::Live,
})
@ -379,7 +380,7 @@ impl ExecutorContext {
.map_err(|e| format!("{:?}", e))?,
)),
fs: Arc::new(FileManager::new(fs_manager)),
stdlib: Arc::new(StdLib::new()),
stdlib: Arc::new(RwLock::new(StdLib::new())),
settings,
context_type: ContextType::Live,
})
@ -392,7 +393,7 @@ impl ExecutorContext {
crate::engine::conn_mock::EngineConnection::new().await.unwrap(),
)),
fs: Arc::new(FileManager::new()),
stdlib: Arc::new(StdLib::new()),
stdlib: Arc::new(RwLock::new(StdLib::new())),
settings: Default::default(),
context_type: ContextType::Mock,
}
@ -410,7 +411,7 @@ impl ExecutorContext {
.map_err(|e| format!("{:?}", e))?,
)),
fs: Arc::new(FileManager::new(fs_manager)),
stdlib: Arc::new(StdLib::new()),
stdlib: Arc::new(RwLock::new(StdLib::new())),
settings,
context_type: ContextType::Mock,
})
@ -421,7 +422,7 @@ impl ExecutorContext {
ExecutorContext {
engine,
fs: Arc::new(FileManager::new()),
stdlib: Arc::new(StdLib::new()),
stdlib: Arc::new(RwLock::new(StdLib::new())),
settings: Default::default(),
context_type: ContextType::MockCustomForwarded,
}
@ -943,7 +944,7 @@ pub(crate) async fn parse_execute(code: &str) -> Result<ExecTestResults, KclErro
})?,
)),
fs: Arc::new(crate::fs::FileManager::new()),
stdlib: Arc::new(crate::std::StdLib::new()),
stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())),
settings: Default::default(),
context_type: ContextType::Mock,
};