<div dir="ltr">Filed it at <a href="https://bugs.launchpad.net/taskflow/+bug/1559496">https://bugs.launchpad.net/taskflow/+bug/1559496</a><div><br></div><div>Thanks,</div><div>Kanthi</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 9:30 PM, Joshua Harlow <span dir="ltr"><<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Interesting error, that could be a bug and perhaps we should ensure upgrade is more thread-safe (with a lock on upgrade); can u open a bug @ <a href="http://bugs.launchpad.net/taskflow" rel="noreferrer" target="_blank">bugs.launchpad.net/taskflow</a> for that and we can try to add said lock (that should hopefully resolve what u are seeing, although if it doesn't then the bug lies somewhere else).<br>
<br>
Thanks much!<br>
<br>
-Josh<div><div class="h5"><br>
<br>
On 03/19/2016 08:45 AM, pnkk wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi Joshua,<br>
<br>
Thanks for all your inputs.<br>
We are using this feature successfully. But I rarely see an issue<br>
related to concurrency.<br>
<br>
To give you a brief, we use eventlets and every job runs in a separate<br>
eventlet thread.<br>
<br>
In the job execution part, we use taskflow functionality and persist all<br>
the details of the job.<br>
<br>
There we try to get the backend as below. We do upgrade everytime when a<br>
job is executed.<br>
<br>
         backend_uri = cfg.CONF.db.sqlalchemy_url<br>
         conf = {<br>
             'connection': backend_uri,<br>
         }<br>
         self.backend = backends.fetch(conf)<br>
         with contextlib.closing(self.backend.get_connection()) as conn:<br>
             conn.upgrade()<br>
<br>
Now when two jobs start executing at the same time, I see below error.<br>
Failed upgrading database version<br>
   DBAPIError: (exceptions.RuntimeError) reentrant call inside<br>
<_io.BufferedReader name=14><br>
<br>
We have monkey patched eventlet, is it not supposed to take care of<br>
these concurrency issues?<br>
<br>
Below are the versions for related modules in use:<br>
eventlet==0.17.4<br>
taskflow==1.26.0<br>
SQLAlchemy==1.0.9<br>
<br>
Thanks,<br>
Kanthi<br>
<br>
On Fri, Feb 12, 2016 at 1:29 PM, Joshua Harlow <<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a><br></div></div><div><div class="h5">
<mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>>> wrote:<br>
<br>
    pn kk wrote:<br>
<br>
        Hi Joshua,<br>
<br>
        Yes, sure will do that once I get some window out of my work.<br>
<br>
        One last query(hopefully :) ) , can the factory method be an<br>
        instance<br>
        method of a class?<br>
<br>
<br>
    Instance methods are particularly hard to use (since they require an<br>
    instance of an object to be useful); so I think the check u have hit<br>
    is making sure that if the flow-factory is called to recreate the<br>
    flow that it can do so without having import issues. Currently I<br>
    believe it doesn't handle instance methods (due to the complexity of<br>
    needing an instance attached to that method).<br>
<br>
    Perhaps what u want is to provide a function that can be found like:<br>
<br>
    def make_flow_factory():<br>
        return FlowFactory().flow_factory<br>
<br>
    Or make flow_factory a class or static method, which should have the<br>
    same/similar effect.<br>
<br>
    Hope that makes sense (more queries are fine and welcome!)<br>
<br>
<br>
        I tried giving it as "FlowFactory().flow_factory", where<br>
        FlowFactory is<br>
        my class name. It failed with below error:<br>
        ValueError: Flow factory <bound method FlowFactory.flow_factory of<br>
        <__main__.FlowFactory instance at 0x2b43b48>> is not reimportable by<br>
        name __builtin__.instance.flow_factory<br>
<br>
        Thanks again<br>
        -Kanthi<br>
<br>
<br>
        On Thu, Jan 28, 2016 at 12:29 AM, Joshua Harlow<br>
        <<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a> <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>><br></div></div><div><div class="h5">
        <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a> <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>>>><br>
        wrote:<br>
<br>
             pn kk wrote:<br>
<br>
                 Hi,<br>
<br>
                 Thanks for the responses. Putting it in a small example<br>
<br>
                 def flow_factory(tmp):<br>
                       return lf.Flow('resume from backend example').add(<br>
                           TestTask(name='first', test=tmp),<br>
                           InterruptTask(name='boom'),<br>
                           TestTask(name='second', test="second task"))<br>
<br>
<br>
                 class TestTask(task.Task):<br>
                       def __init__(self, name, provides=None, test,<br>
        **kwargs):<br>
                           self.test=test<br>
                           super(TestTask, self).__init__(name,<br>
        provides, **kwargs)<br>
                       def execute(self, *args, **kwargs):<br>
                           print('executing %s' % self)<br>
                           return 'ok'<br>
<br>
                 class InterruptTask(task.Task):<br>
                       def execute(self, *args, **kwargs):<br>
                           # DO NOT TRY THIS AT HOME<br>
                           engine.suspend()<br>
<br>
                 I was searching for a way in which I can reload the<br>
        flow after crash<br>
                 without passing the parameter "tmp" shown above<br>
                 Looks like "load_from_factory" gives this provision.<br>
<br>
<br>
             Thanks for the example, ya, this is one such way to do this<br>
        that u<br>
             have found, there are a few other ways, but that is the<br>
        main one<br>
             that people should be using.<br>
<br>
<br>
<br>
                 engine =<br>
<br>
        taskflow.engines.load_from_factory(flow_factory=flow_factory,<br>
                 factory_kwargs={"tmp":"test_data"}, book=book,<br>
        backend=backend)<br>
                 engine.run()<br>
<br>
                 Now it suspends after running interrupt task, I can now<br>
        reload<br>
                 the flow<br>
                 from the saved factory method without passing parameter<br>
        again.<br>
                 for flow_detail_2 in book:<br>
                       engine2 =<br>
        taskflow.engines.load_from_detail(flow_detail_2,<br>
                 backend=backend)<br>
<br>
                 engine2.run()<br>
<br>
                 Let me know if this is ok or is there a better approach to<br>
                 achieve this?<br>
<br>
<br>
             There are a few other ways, but this one should be the<br>
        currently<br>
             recommended one.<br>
<br>
             An idea, do u want to maybe update (submit a review to<br>
        update) the<br>
             docs, if u didn't find this very easy to figure out so that<br>
        others<br>
             can more easily figure it out. I'm sure that would be<br>
        appreciated by<br>
             all.<br>
<br>
<br>
                 -Thanks<br>
<br>
<br>
                 On Wed, Jan 27, 2016 at 12:03 AM, Joshua Harlow<br>
                 <<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a> <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>><br>
        <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a> <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>>><br>
                 <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a><br>
        <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>> <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a><br>
        <mailto:<a href="mailto:harlowja@fastmail.com" target="_blank">harlowja@fastmail.com</a>>>>><br>
<br>
                 wrote:<br>
<br>
                      Hi there,<br>
<br>
                      Michał is correct, it should be saved.<br>
<br>
                      Do u have a small example of what u are trying to do<br>
                 because that<br>
                      will help determine if what u are doing will be<br>
        saved or<br>
                 whether it<br>
                      will not be.<br>
<br>
                      Or even possibly explaining what is being done<br>
        would be fine to<br>
                      (more data/info for me to reason about what should be<br>
                 stored in your<br>
                      case).<br>
<br>
                      Thanks,<br>
<br>
                      Josh<br>
<br>
<br>
                      Michał Dulko wrote:<br>
<br>
                          On 01/26/2016 10:23 AM, pn kk wrote:<br>
<br>
                              Hi,<br>
<br>
                              I use taskflow for job management and now<br>
        trying to<br>
                 persist<br>
                              the state<br>
                              of flows/tasks in mysql to recover incase of<br>
                 process crashes.<br>
<br>
                              I could see the state and the task results<br>
        stored<br>
                 in the<br>
                              database.<br>
<br>
                              Now I am looking for some way to store the<br>
        input<br>
                 parameters<br>
                              of the tasks.<br>
<br>
                              Please share your inputs to achieve this.<br>
<br>
                              -Thanks<br>
<br>
                          I've played with that some time ago and if I<br>
        recall<br>
                 correctly input<br>
                          parameters should be available in the flow's<br>
        storage, which<br>
                          means these<br>
                          are also saved to the DB. Take a look on<br>
                 resume_workflows method<br>
                          on my<br>
                          old PoC [1] (hopefully TaskFlow haven't<br>
        changed much<br>
                 since then).<br>
<br>
                          [1]<br>
        <a href="https://review.openstack.org/#/c/152200/4/cinder/scheduler/manager.py" rel="noreferrer" target="_blank">https://review.openstack.org/#/c/152200/4/cinder/scheduler/manager.py</a><br>
<br>
<br>
<br>
        __________________________________________________________________________<br>
                          OpenStack Development Mailing List (not for usage<br>
                 questions)<br>
                          Unsubscribe:<br>
        <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
        <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
<br>
<br>
        __________________________________________________________________________<br>
                      OpenStack Development Mailing List (not for usage<br>
        questions)<br>
                      Unsubscribe:<br>
        <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
        <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
<br>
        __________________________________________________________________________<br>
                 OpenStack Development Mailing List (not for usage<br>
        questions)<br>
                 Unsubscribe:<br>
        <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
        <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
<br>
        __________________________________________________________________________<br>
             OpenStack Development Mailing List (not for usage questions)<br>
             Unsubscribe:<br>
        <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
<br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
        <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
        __________________________________________________________________________<br>
        OpenStack Development Mailing List (not for usage questions)<br>
        Unsubscribe:<br>
        <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
        <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
        <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
    __________________________________________________________________________<br>
    OpenStack Development Mailing List (not for usage questions)<br>
    Unsubscribe:<br>
    <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
    <<a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>><br>
    <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
<br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
</div></div></blockquote><div class="HOEnZb"><div class="h5">
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div></div></blockquote></div><br></div>