summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin/helpers.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugin/helpers.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py
index a9e7b6067..894ed9851 100644
--- a/src/lib/Bcfg2/Server/Plugin/helpers.py
+++ b/src/lib/Bcfg2/Server/Plugin/helpers.py
@@ -164,18 +164,21 @@ class DatabaseBacked(Plugin):
return False
@staticmethod
- def get_db_lock(fn):
+ def get_db_lock(func):
""" Decorator to be used by a method of a
:class:`DatabaseBacked` plugin that will update database data. """
+
+ @wraps(func)
def _acquire_and_run(self, *args, **kwargs):
+ """ The decorated function """
if self._must_lock: # pylint: disable=W0212
try:
self.core.db_write_lock.acquire()
- rv = fn(self, *args, **kwargs)
+ rv = func(self, *args, **kwargs)
finally:
self.core.db_write_lock.release()
else:
- rv = fn(self, *args, **kwargs)
+ rv = func(self, *args, **kwargs)
return rv
return _acquire_and_run