Restricting Multiple Flow Executions

Post your questions and help other users.

Moderator: Martin

Post Reply
98b427af

Restricting Multiple Flow Executions

Post by 98b427af » 03 Apr 2014 21:27

I have some flows that end up being executed more than once at the same time, due to overlapping triggers or invocation from other flows. For some of those I don't want them to execute more than once simultaneously. How can I "lock" a flow so that it's guaranteed that if it is executed more than once at the same time, only the first execution continues and all others exit?

I've tried a few things but I always end up with race conditions or other problems.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Restricting Multiple Flow Executions

Post by MURTUMA » 03 Apr 2014 21:51

It's not nativelly possible yet but as far as I know, Martin's working on native support for this. However, this workaround should work in your situation:

Right after the trigger, add ACTION: SET FLOW STATE; DISABLE and then continue your flow regularly. Then add ACTION: SET FLOW STATE; ENABLE, as a last action. This prevents the flow triggering while it's running.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Restricting Multiple Flow Executions

Post by Martin » 04 Apr 2014 10:27

That's correct, there will be new options in the next version of Automagic to handle such cases (available in the EAP-version, not tested very well yet).
When editing a flow, select menu->Options and select either 'Skip...', 'Wait...' or 'Stop the currently executing instance and execute afterwards'.

User avatar
Nerey
Posts: 102
Joined: 07 Mar 2014 16:59

Re: Restricting Multiple Flow Executions

Post by Nerey » 04 Apr 2014 18:18

Hey, why you don't want to use condition Flow Executing? It provides a variable flow_execution_contexts.
Here is solution:
First after trigger goes condition Flow Executing with the same flow executing. It is understood that it always be true.
Next comes condition Expression flow_execution_contexts == 1. Flow continues execution only if true.

By the way, using Disable/Enable flow you can forgot enable it in all cases. And you can't easily stop flow, you should enable it again manually.
Sorry for bad english, my native is russian.

98b427af

Re: Restricting Multiple Flow Executions

Post by 98b427af » 14 Apr 2014 14:33

I'm running tests using both enable/disable and Flow Executing. So far it seems that both are fine as long as the only concern is the flow being executed simultaneously (or nearly simultaneously) by its own triggers. Things seem to get complicated, though, when there is the possibility that the flow can also be executed by another flow. The results on that are not yet in.

Post Reply