summaryrefslogtreecommitdiff
path: root/cloudinit/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/helpers.py')
-rw-r--r--cloudinit/helpers.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 4447d1ee..b6974f3c 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -40,13 +40,17 @@ class LockFailure(Exception):
pass
+class DummyLock(object):
+ pass
+
+
class DummySemaphores(object):
def __init__(self):
pass
@contextlib.contextmanager
def lock(self, _name, _freq, _clear_on_fail=False):
- yield True
+ yield DummyLock()
def has_run(self, _name, _freq):
return False
@@ -58,6 +62,11 @@ class DummySemaphores(object):
pass
+class FileLock(object):
+ def __init__(self, fn):
+ self.fn = fn
+
+
class FileSemaphores(object):
def __init__(self, sem_path):
self.sem_path = sem_path
@@ -101,7 +110,7 @@ class FileSemaphores(object):
except (IOError, OSError):
util.logexc(LOG, "Failed writing semaphore file %s", sem_file)
return None
- return sem_file
+ return FileLock(sem_file)
def has_run(self, name, freq):
if not freq or freq == PER_ALWAYS:
@@ -158,8 +167,8 @@ class Runners(object):
if not lk:
raise LockFailure("Failed to acquire lock for %s" % name)
else:
- LOG.debug("Running %s with args %s using lock %s (%s)",
- functor, args, util.obj_name(lk), lk)
+ LOG.debug("Running %s with args %s using lock (%s)",
+ functor, args, lk)
if isinstance(args, (dict)):
results = functor(**args)
else: