Replace std::sync::Mutex with parking_lot::Mutex in languages/src/python.rs (#29889)

This appears to be the only place `std::sync::Mutex` is used, Zed always
prefers `parking_lot`.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-05-04 15:12:21 -06:00 committed by GitHub
parent f4e9ea3cd8
commit 86484233c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 8 deletions

1
Cargo.lock generated
View file

@ -7992,6 +7992,7 @@ dependencies = [
"log", "log",
"lsp", "lsp",
"node_runtime", "node_runtime",
"parking_lot",
"paths", "paths",
"pet", "pet",
"pet-conda", "pet-conda",

View file

@ -46,6 +46,7 @@ language.workspace = true
log.workspace = true log.workspace = true
lsp.workspace = true lsp.workspace = true
node_runtime.workspace = true node_runtime.workspace = true
parking_lot.workspace = true
paths.workspace = true paths.workspace = true
pet-conda.workspace = true pet-conda.workspace = true
pet-core.workspace = true pet-core.workspace = true

View file

@ -23,8 +23,8 @@ use serde_json::{Value, json};
use smol::lock::OnceCell; use smol::lock::OnceCell;
use std::cmp::Ordering; use std::cmp::Ordering;
use parking_lot::Mutex;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Mutex;
use std::{ use std::{
any::Any, any::Any,
borrow::Cow, borrow::Cow,
@ -671,7 +671,6 @@ impl ToolchainLister for PythonToolchainProvider {
let mut toolchains = reporter let mut toolchains = reporter
.environments .environments
.lock() .lock()
.ok()
.map_or(Vec::new(), |mut guard| std::mem::take(&mut guard)); .map_or(Vec::new(), |mut guard| std::mem::take(&mut guard));
let wr = worktree_root; let wr = worktree_root;
@ -823,7 +822,7 @@ impl pet_core::os_environment::Environment for EnvironmentApi<'_> {
} }
fn get_know_global_search_locations(&self) -> Vec<PathBuf> { fn get_know_global_search_locations(&self) -> Vec<PathBuf> {
if self.global_search_locations.lock().unwrap().is_empty() { if self.global_search_locations.lock().is_empty() {
let mut paths = let mut paths =
std::env::split_paths(&self.get_env_var("PATH".to_string()).unwrap_or_default()) std::env::split_paths(&self.get_env_var("PATH".to_string()).unwrap_or_default())
.collect::<Vec<PathBuf>>(); .collect::<Vec<PathBuf>>();
@ -840,12 +839,9 @@ impl pet_core::os_environment::Environment for EnvironmentApi<'_> {
.filter(|p| p.exists()) .filter(|p| p.exists())
.collect::<Vec<PathBuf>>(); .collect::<Vec<PathBuf>>();
self.global_search_locations self.global_search_locations.lock().append(&mut paths);
.lock()
.unwrap()
.append(&mut paths);
} }
self.global_search_locations.lock().unwrap().clone() self.global_search_locations.lock().clone()
} }
} }