mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
actionsmap: add global flag to disable cache and lock
This commit is contained in:
parent
964483b23b
commit
ef08a8be53
2 changed files with 8 additions and 3 deletions
|
@ -414,6 +414,9 @@ class ActionsMap(object):
|
|||
# Read actions map from yaml file
|
||||
actionsmap = read_yaml(actionsmap_yml)
|
||||
|
||||
if not actionsmap["_global"].get("cache", True):
|
||||
return actionsmap
|
||||
|
||||
# Delete old cache files
|
||||
for old_cache in glob.glob(f"{actionsmap_yml_dir}/.{actionsmap_yml_file}.*.pkl"):
|
||||
os.remove(old_cache)
|
||||
|
@ -536,7 +539,7 @@ class ActionsMap(object):
|
|||
full_action_name = "%s.%s.%s" % (namespace, category, action)
|
||||
|
||||
# Lock the moulinette for the namespace
|
||||
with MoulinetteLock(namespace, timeout):
|
||||
with MoulinetteLock(namespace, timeout, self.enable_lock):
|
||||
start = time()
|
||||
try:
|
||||
mod = __import__(
|
||||
|
@ -618,6 +621,7 @@ class ActionsMap(object):
|
|||
_global = actionsmap.pop("_global", {})
|
||||
|
||||
self.namespace = _global["namespace"]
|
||||
self.enable_lock = _global.get("lock", True)
|
||||
self.default_authentication = _global["authentication"][
|
||||
interface_type
|
||||
]
|
||||
|
|
|
@ -291,10 +291,11 @@ class MoulinetteLock(object):
|
|||
|
||||
base_lockfile = "/var/run/moulinette_%s.lock"
|
||||
|
||||
def __init__(self, namespace, timeout=None, interval=0.5):
|
||||
def __init__(self, namespace, timeout=None, enable_lock=True, interval=0.5):
|
||||
self.namespace = namespace
|
||||
self.timeout = timeout
|
||||
self.interval = interval
|
||||
self.enable_lock = enable_lock
|
||||
|
||||
self._lockfile = self.base_lockfile % namespace
|
||||
self._stale_checked = False
|
||||
|
@ -421,7 +422,7 @@ class MoulinetteLock(object):
|
|||
return False
|
||||
|
||||
def __enter__(self):
|
||||
if not self._locked:
|
||||
if self.enable_lock and not self._locked:
|
||||
self.acquire()
|
||||
return self
|
||||
|
||||
|
|
Loading…
Reference in a new issue