Pass through run timeout in engine run()

It can be quite useful to control the delay/timeout
used during waiting periods via the run() method and
not requiring the usage of run_iter() to achieve the
same thing.

This change makes it possible to pass the same timeout
used in run_iter() to run() and have it be used in the
engine internals.

Change-Id: I3798ee14600a2d30e009abf1f273b5edbbe3f5ed
This commit is contained in:
Joshua Harlow
2015-12-03 10:44:20 -08:00
parent aba52d5962
commit f5cd0632aa

View File

@@ -187,12 +187,18 @@ class ActionEngine(base.Engine):
backend=self._backend,
scope_fetcher=_scope_fetcher)
def run(self):
def run(self, timeout=None):
"""Runs the engine (or die trying).
:param timeout: timeout to wait for any atoms to complete (this timeout
will be used during the waiting period that occurs when
unfinished atoms are being waited on).
"""
with fasteners.try_lock(self._lock) as was_locked:
if not was_locked:
raise exc.ExecutionFailure("Engine currently locked, please"
" try again later")
for _state in self.run_iter():
for _state in self.run_iter(timeout=timeout):
pass
def run_iter(self, timeout=None):