diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-09-17 16:09:59 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-09-17 16:09:59 -0700 |
commit | fb73979345d16b4912ea1f6da148d35c676a6576 (patch) | |
tree | 86b6119d0519c5a9823e2d8e814470cf3996f9cd /lib | |
parent | e17ad6a684b94211e9b4267cca68cc7fdf6ad277 (diff) | |
download | spack-fb73979345d16b4912ea1f6da148d35c676a6576.tar.gz spack-fb73979345d16b4912ea1f6da148d35c676a6576.tar.bz2 spack-fb73979345d16b4912ea1f6da148d35c676a6576.tar.xz spack-fb73979345d16b4912ea1f6da148d35c676a6576.zip |
Allow custom timeout for database locking.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/database.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index cea56eb1b9..e74217a262 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -44,6 +44,8 @@ _db_dirname = '.spack-db' # DB version. This is stuck in the DB file to track changes in format. _db_version = Version('0.9') +# Default timeout for spack database locks is 5 min. +_db_lock_timeout = 300 def _autospec(function): """Decorator that automatically converts the argument of a single-arg @@ -100,14 +102,14 @@ class Database(object): self._last_write_time = 0 - def write_lock(self): + def write_lock(self, timeout=_db_lock_timeout): """Get a write lock context for use in a `with` block.""" - return self.lock.write_lock() + return self.lock.write_lock(timeout) - def read_lock(self): + def read_lock(self, timeout=_db_lock_timeout): """Get a read lock context for use in a `with` block.""" - return self.lock.read_lock() + return self.lock.read_lock(timeout) def _write_to_yaml(self, stream): |