Skip to content

Commit

Permalink
toolchains: Run listing tasks on background thread
Browse files Browse the repository at this point in the history
Potentially fixes #21404
  • Loading branch information
osiewicz committed Dec 2, 2024
1 parent 995b40f commit 84b190c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/language/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Toolchain {
pub as_json: serde_json::Value,
}

#[async_trait(?Send)]
#[async_trait]
pub trait ToolchainLister: Send + Sync {
async fn list(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/languages/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ fn env_priority(kind: Option<PythonEnvironmentKind>) -> usize {
}
}

#[async_trait(?Send)]
#[async_trait]
impl ToolchainLister for PythonToolchainProvider {
async fn list(
&self,
Expand Down
11 changes: 6 additions & 5 deletions crates/project/src/toolchain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,12 @@ impl LocalToolchainStore {
.ok()?
.await;
let language = registry.language_for_name(&language_name.0).await.ok()?;
let toolchains = language
.toolchain_lister()?
.list(root.to_path_buf(), project_env)
.await;
Some(toolchains)
let toolchains = language.toolchain_lister()?;
Some(
cx.background_executor()
.spawn(async move { toolchains.list(root.to_path_buf(), project_env).await })
.await,
)
})
}
pub(crate) fn active_toolchain(
Expand Down

0 comments on commit 84b190c

Please sign in to comment.