-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
enhancementNew feature or improvement to existing functionalityNew feature or improvement to existing functionalityinternalA refactor or improvement that is not user-facingA refactor or improvement that is not user-facing
Description
We need to ensure that there a no race conditions when two uv subcommands in parallel. This includes:
- Parallel filesystem modifications in interpreters/venvs
- TOCTOU differences between determining packages and performing changes
- Installing as well as parallel editing of
pyproject.toml, including TOCTOU errors with
We already enforce these guarantees with locks for most subcommands. (Follow-up to #12751.)
The required locking generally applies to operations of the same kind, such as uv sync, but it can also be cross-operation, e.g. uv pip list could fail reading the installed packages if uv sync removes some mid-operation.
An exception is the cache, where we use symlinks for atomic operations to allow safe parallel modification. If we need multiple locks, e.g. pyproject.toml and the interpreter, we should define and document an order for the locks and use it globally to prevent deadlocks.
Important
- Ensure that
uv runlocks when syncing the envirnoment.
uv runcalls the same logic asuv syncinternally, so we can use the same locking pattern
Prevent concurrent updates of the environment inuv run#14153 - Ensure that
uv version --bumplocks when syncing the environment. - Lock build directories for setuptools (concurrent wheel builds fail oddly #13703)
Lock the source tree when running setuptools, to protect concurrent builds #14174 - Ensure that all other subcommands already use the correct locking.
-
uv cacheoperations don't clash with other uv operations Makeuv cache cleanparallel process safe #15888
Less Important
- Determine if there are reliable testing strategies, when uv testing currently uses subprocesses.
Integrating shuttle is not feasible with several uv processes, but maybe a script that locally runs all modifying uv subcommands in a loop in parallel and verifies that we en in a sound state? -
uv add,uv removeanduv version --bumpshould lockpyproject.tomlbefore computing edits.
The use case here is that these operations may be started by an IDE/LSP while another operation is e.g. still in its sync phase and/or may roll back in the end.
We can likely test this by having a build we control in the sync phase. -
uv addanduv removeshould not lock a global interpreter path when they're not actually going to sync anything (e.g. inline script metadata without an existing cached or locked venv)
Nice to have
- Are there portable filesystem read-write locks to allow e.g. blocking
uv pip listfrom reading whileuv syncis editing? - Does
uv init/uv venvand venv creation in general need to lock?
b-phi
Metadata
Metadata
Assignees
Labels
enhancementNew feature or improvement to existing functionalityNew feature or improvement to existing functionalityinternalA refactor or improvement that is not user-facingA refactor or improvement that is not user-facing