def prefix_lock(self, spec): """Get a lock on a particular spec's installation directory. NOTE: The installation directory **does not** need to exist. Prefix lock is a byte range lock on the nth byte of a file. The lock file is ``spack.store.db.prefix_lock`` -- the DB tells us what to call it and it lives alongside the install DB. n is the sys.maxsize-bit prefix of the DAG hash. This makes likelihood of collision is very low AND it gives us readers-writer lock semantics with just a single lockfile, so no cleanup required. """ prefix = spec.prefix if prefix not in self._prefix_locks: self._prefix_locks[prefix] = Lock( self.prefix_lock_path, spec.dag_hash_bit_prefix(bit_length(sys.maxsize)), 1) return self._prefix_locks[prefix]
def prefix_lock(self, spec): """Get a lock on a particular spec's installation directory. NOTE: The installation directory **does not** need to exist. Prefix lock is a byte range lock on the nth byte of a file. The lock file is ``spack.store.db.prefix_lock`` -- the DB tells us what to call it and it lives alongside the install DB. n is the sys.maxsize-bit prefix of the DAG hash. This makes likelihood of collision is very low AND it gives us readers-writer lock semantics with just a single lockfile, so no cleanup required. """ prefix = spec.prefix if prefix not in self._prefix_locks: self._prefix_locks[prefix] = Lock( self.prefix_lock_path, spec.dag_hash_bit_prefix(bit_length(sys.maxsize)), 1) return self._prefix_locks[prefix]