mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-16 05:20:04 +00:00
Avoid deadlocks when multiple uv processes lock resources (#6790)
This is achieved by updating the `LockedFile::acquire` API to be async —
as in some cases we were attempting to acquire the lock synchronously,
i.e., without yielding, which blocked the runtime.
Closes https://github.com/astral-sh/uv/issues/6691 — I tested with the
reproduction there and a local release build and no longer reproduce the
deadlock with these changes.
Some additional context in the [internal Discord
thread](1278478941
)
This commit is contained in:
parent
4f5356ed55
commit
e3d5d3d26d
19 changed files with 58 additions and 39 deletions
|
@ -69,12 +69,10 @@ impl ManagedPythonInstallations {
|
|||
Self { root: root.into() }
|
||||
}
|
||||
|
||||
/// Lock the toolchains directory.
|
||||
pub fn acquire_lock(&self) -> Result<LockedFile, Error> {
|
||||
Ok(LockedFile::acquire(
|
||||
self.root.join(".lock"),
|
||||
self.root.user_display(),
|
||||
)?)
|
||||
/// Grab a file lock for the managed Python distribution directory to prevent concurrent access
|
||||
/// across processes.
|
||||
pub async fn lock(&self) -> Result<LockedFile, Error> {
|
||||
Ok(LockedFile::acquire(self.root.join(".lock"), self.root.user_display()).await?)
|
||||
}
|
||||
|
||||
/// Prefer, in order:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue