summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/helpers.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 16548001..e5f33a26 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -49,8 +49,14 @@ class DummySemaphores(object):
def has_run(self, _name, _freq):
return False
+ def clear(self, _name, _freq):
+ return True
+
+ def clear_all(self):
+ pass
+
-class Semaphores(object):
+class FileSemaphores(object):
def __init__(self, sem_path):
self.sem_path = sem_path
@@ -71,6 +77,12 @@ class Semaphores(object):
return False
return True
+ def clear_all(self):
+ try:
+ util.del_dir(self.sem_path)
+ except (IOError, OSError):
+ pass
+
def _acquire(self, name, freq):
if self.has_run(name, freq):
return None
@@ -117,7 +129,7 @@ class Runners(object):
if not sem_path:
return None
if sem_path not in self.sems:
- self.sems[sem_path] = Semaphores(sem_path)
+ self.sems[sem_path] = FileSemaphores(sem_path)
return self.sems[sem_path]
def run(self, name, functor, args, freq=None, clear_on_fail=False):