From f5cd0632aad368d8f4500b34e64618014900af61 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 3 Dec 2015 10:44:20 -0800 Subject: [PATCH] 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 --- taskflow/engines/action_engine/engine.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/taskflow/engines/action_engine/engine.py b/taskflow/engines/action_engine/engine.py index 36ab11b2..53151107 100644 --- a/taskflow/engines/action_engine/engine.py +++ b/taskflow/engines/action_engine/engine.py @@ -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):