<div dir="ltr">thanks Michael,<div><br></div><div>I am aware that executor can be reused by different engines. </div><div>My query was regarding if multiple engines can share same thread for running the engines(and not the tasks of those engines).</div><div><br></div><div>I tried run_iter which can be used to run multiple engines but the tasks of individual engines are run one after another.</div><div>Probably engine is holding on to the thread.</div><div><br></div><div>This is limiting our ability run multiple workflows (i.e. engines) in parallel.</div><div><br></div><div>My query is - is it possible to run multiple engines in parallel on same thread (using some asynchronous task execution)</div><div> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 27, 2020 at 3:18 AM Michael Johnson <<a href="mailto:johnsomor@gmail.com">johnsomor@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Sachin,<br>
<br>
I'm not 100% sure I understand your need, but I will attempt to answer<br>
and you can correct me if I am off base.<br>
<br>
Taskflow engines (you can create as many of these as you want) use an<br>
executor defined at flow load time.<br>
<br>
Here is a snippet from the Octavia code:<br>
        self.executor = concurrent.futures.ThreadPoolExecutor(<br>
            max_workers=CONF.task_flow.max_workers)<br>
        eng = tf_engines.load(<br>
            flow,<br>
            engine=CONF.task_flow.engine,<br>
            executor=self.executor,<br>
            never_resolve=CONF.task_flow.disable_revert,<br>
            **kwargs)<br>
<br>
The parts you are likely interested in are:<br>
<br>
1. The executor. In this case we are using a<br>
concurrent.futures.ThreadPoolExecutor. We then set the max_workers<br>
setting to the number of threads we want in our taskflow engine thread<br>
pool.<br>
2. During flow load, we define the engine to be 'parallel' (note:<br>
'serial' is the default). This means that unordered flows will run in<br>
parallel as opposed to serially.<br>
3. As noted in the documentation[1], You can share an executor between<br>
taskflow engines to share the thread pool.<br>
<br>
Finally, you want to use "unordered" flows or sub-flows to execute<br>
tasks concurrently.<br>
<br>
[1] <a href="https://docs.openstack.org/taskflow/latest/user/engines.html#parallel" rel="noreferrer" target="_blank">https://docs.openstack.org/taskflow/latest/user/engines.html#parallel</a><br>
<br>
Michael<br>
<br>
On Wed, Feb 26, 2020 at 7:19 AM Sachin Laddha <<a href="mailto:sachinladdha@gmail.com" target="_blank">sachinladdha@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> We are using taskflow to execute workflows. Each workflow is executed by a separate thread (using engine.run() method). This is limiting our capability to execute maximum number of workflows that can run in parallel. It is limited by the number of threads there in the thread pool.<br>
><br>
> Most of the time, the workflow tasks are run by agents which could take some time to complete. Each engine is alive and runs on a dedicated thread.<br>
><br>
> Is there any way to reuse or run multiple engines on one thread. The individual tasks of these engines can run in parallel.<br>
><br>
> I came across iter_run method of the engine class. But not sure if that can be used for this purpose.<br>
><br>
> Any help is highly appreciated.<br>
</blockquote></div>