toolchains: Run listing tasks on background thread (#21414)
Potentially fixes #21404 This is a speculative fix, as while I was trying to repro this issue I've noticed that introducing artificial delays in ToolchainLister::list could impact apps responsiveness. These delays were essentially there to stimulate PET taking a while to find venvs. Release Notes: - Improved app responsiveness in environments with multiple Python virtual environments
This commit is contained in:
parent
b88daae67b
commit
59dc6cf523
3 changed files with 10 additions and 8 deletions
|
@ -24,7 +24,7 @@ pub struct Toolchain {
|
||||||
pub as_json: serde_json::Value,
|
pub as_json: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait]
|
||||||
pub trait ToolchainLister: Send + Sync {
|
pub trait ToolchainLister: Send + Sync {
|
||||||
async fn list(
|
async fn list(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -536,7 +536,7 @@ fn env_priority(kind: Option<PythonEnvironmentKind>) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait]
|
||||||
impl ToolchainLister for PythonToolchainProvider {
|
impl ToolchainLister for PythonToolchainProvider {
|
||||||
async fn list(
|
async fn list(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -311,12 +311,14 @@ impl LocalToolchainStore {
|
||||||
})
|
})
|
||||||
.ok()?
|
.ok()?
|
||||||
.await;
|
.await;
|
||||||
let language = registry.language_for_name(&language_name.0).await.ok()?;
|
|
||||||
let toolchains = language
|
cx.background_executor()
|
||||||
.toolchain_lister()?
|
.spawn(async move {
|
||||||
.list(root.to_path_buf(), project_env)
|
let language = registry.language_for_name(&language_name.0).await.ok()?;
|
||||||
.await;
|
let toolchains = language.toolchain_lister()?;
|
||||||
Some(toolchains)
|
Some(toolchains.list(root.to_path_buf(), project_env).await)
|
||||||
|
})
|
||||||
|
.await
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub(crate) fn active_toolchain(
|
pub(crate) fn active_toolchain(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue