fix: thread-safe hub_trust check_and_pin — eliminate parallel-pack warnings
Parallel pack uploads (_PACK_WORKERS=8 threads) all call check_and_pin() simultaneously. The old code: each thread writes to the same .toml.tmp path then calls os.replace(tmp, hub_trust.toml). Race:
Thread A: writes .toml.tmp Thread B: writes .toml.tmp (overwrites A's content) Thread A: os.replace(.toml.tmp, hub_trust.toml) ← succeeds, deletes .tmp Thread B: os.replace(.toml.tmp, hub_trust.toml) ← FAILS, .tmp is gone → '[Errno 2] No such file or directory' warning x4 per 8-pack push
Fix: _TRUST_LOCK = threading.Lock() guards the entire read-modify-write cycle (load_hub_trust_store → update → _save_hub_trust_store).
The slow part (TLS handshake via _cert_fingerprint_from_response) runs BEFORE acquiring the lock, so threads only serialize on the file I/O portion (~microseconds), not on the network round-trip.
0 comments
muse hub commit comment sha256:b4cbb591e22097e5d224fca501da5569fdf31a75c2a7c81d4fc1fc499afa4d0a --body "your comment"
No comments yet. Be the first to start the discussion.