summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-29 08:50:50 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-29 08:57:14 -0400
commit0d7e708d7a75d0aaa9e2ff56ee6445a07998f6fe (patch)
treed166d4f5492273842772474e19f85ec3e5b06b21 /src/lib/Bcfg2/Server/Plugin
parentf60ab7ec8a1d5d090c272887d777d4635f95df49 (diff)
downloadbcfg2-0d7e708d7a75d0aaa9e2ff56ee6445a07998f6fe.tar.gz
bcfg2-0d7e708d7a75d0aaa9e2ff56ee6445a07998f6fe.tar.bz2
bcfg2-0d7e708d7a75d0aaa9e2ff56ee6445a07998f6fe.zip
added database locking to Metadata
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin')
-rw-r--r--src/lib/Bcfg2/Server/Plugin/helpers.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py
index c7798b705..a9e7b6067 100644
--- a/src/lib/Bcfg2/Server/Plugin/helpers.py
+++ b/src/lib/Bcfg2/Server/Plugin/helpers.py
@@ -151,22 +151,24 @@ class DatabaseBacked(Plugin):
@property
def _must_lock(self):
- """ Whether or not the backend database allows multiple
- threads to write. """
- engine = self.core.setup.cfp.get(Bcfg2.Options.DB_ENGINE.cf[0],
- Bcfg2.Options.DB_ENGINE.cf[1],
- default=Bcfg2.Options.DB_ENGINE.default)
+ """ Whether or not the backend database must acquire a thread
+ lock before writing, because it does not allow multiple
+ threads to write."""
+ engine = \
+ self.core.setup.cfp.get(Bcfg2.Options.DB_ENGINE.cf[0],
+ Bcfg2.Options.DB_ENGINE.cf[1],
+ default=Bcfg2.Options.DB_ENGINE.default)
if engine == 'sqlite3':
return True
else:
return False
@staticmethod
- def _db_writer(fn):
- """ Decorator to be used when a call will update the data
- threads to write. """
+ def get_db_lock(fn):
+ """ Decorator to be used by a method of a
+ :class:`DatabaseBacked` plugin that will update database data. """
def _acquire_and_run(self, *args, **kwargs):
- if self._must_lock:
+ if self._must_lock: # pylint: disable=W0212
try:
self.core.db_write_lock.acquire()
rv = fn(self, *args, **kwargs)