Skip to content

Commit 5beccc3

Browse files
committed
fix: add configure logging and move glob expansion outside write lock
1 parent 2229bd1 commit 5beccc3

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

crates/pet/src/jsonrpc.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,35 @@ pub fn handle_configure(context: Arc<Context>, id: u32, params: Value) {
115115
Ok(configure_options) => {
116116
// Start in a new thread, we can have multiple requests.
117117
thread::spawn(move || {
118-
let mut cfg = context.configuration.write().unwrap();
119-
// Expand glob patterns in workspace_directories
120-
cfg.workspace_directories = configure_options.workspace_directories.map(|dirs| {
118+
info!("Received configure request");
119+
let now = SystemTime::now();
120+
121+
// Expand glob patterns before acquiring the write lock so we
122+
// don't block readers/writers while traversing the filesystem.
123+
let workspace_directories = configure_options.workspace_directories.map(|dirs| {
124+
trace!("Expanding workspace directory patterns: {:?}", dirs);
121125
expand_glob_patterns(&dirs)
122126
.into_iter()
123127
.filter(|p| p.is_dir())
124128
.collect()
125129
});
126-
cfg.conda_executable = configure_options.conda_executable;
127-
// Expand glob patterns in environment_directories
128-
cfg.environment_directories =
130+
let environment_directories =
129131
configure_options.environment_directories.map(|dirs| {
132+
trace!("Expanding environment directory patterns: {:?}", dirs);
130133
expand_glob_patterns(&dirs)
131134
.into_iter()
132135
.filter(|p| p.is_dir())
133136
.collect()
134137
});
138+
trace!(
139+
"Glob expansion completed in {:?}",
140+
now.elapsed().unwrap_or_default()
141+
);
142+
143+
let mut cfg = context.configuration.write().unwrap();
144+
cfg.workspace_directories = workspace_directories;
145+
cfg.conda_executable = configure_options.conda_executable;
146+
cfg.environment_directories = environment_directories;
135147
cfg.pipenv_executable = configure_options.pipenv_executable;
136148
cfg.poetry_executable = configure_options.poetry_executable;
137149
// We will not support changing the cache directories once set.
@@ -146,6 +158,10 @@ pub fn handle_configure(context: Arc<Context>, id: u32, params: Value) {
146158
for locator in context.locators.iter() {
147159
locator.configure(&config);
148160
}
161+
info!(
162+
"Configure completed in {:?}",
163+
now.elapsed().unwrap_or_default()
164+
);
149165
send_reply(id, None::<()>);
150166
});
151167
}

0 commit comments

Comments
 (0)