Skip to content

Add cross-platform file lock for concurrent venv installs (parity with JS bootstrap) #62

Description

@ar7casper

Context

When openant is invoked while another openant invocation is already running, two concurrent pip install -e <core> calls can race on the same ~/.openant/venv/. pip is not safe under concurrent installs to the same environment — typical failure modes include corrupted RECORD files, partial wheel extraction, and broken .dist-info metadata.

Two related code paths today have inconsistent treatment of this concurrency problem:

The gap

For users with even simple parallel workflows (e.g. openant scan A & openant scan B, or two terminals doing openant parse <repo> simultaneously), the venv install path can race. JS bootstrap is safe; venv install is not.

Proposed approach

Add a Go-side file lock around the pip install -e call in CheckOpenantInstalled and CheckDepsStale. Two candidate implementations:

  1. golang.org/x/sys/unix.Flock + golang.org/x/sys/windows.LockFileEx — direct OS calls, portable behind a build-tag wrapper.
  2. github.com/gofrs/flock — third-party, cross-platform, ~200 LOC of dependency.

Option 1 aligns better with the "no extra dependencies" preference but requires platform-specific Go files. Option 2 is one import.

Lock target: ~/.openant/venv/.deps-install.lock. Same acquisition pattern as parsers/javascript/_file_lock (block-until-acquired, re-check sentinel inside lock).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions