Skip to content

Instantly share code, notes, and snippets.

@iNecas
Created February 24, 2017 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iNecas/4ad20c1451f46ef91b198ed5e9fdd413 to your computer and use it in GitHub Desktop.
Save iNecas/4ad20c1451f46ef91b198ed5e9fdd413 to your computer and use it in GitHub Desktop.
diff --git a/lib/dynflow/action/with_bulk_sub_plans.rb b/lib/dynflow/action/with_bulk_sub_plans.rb
index dbff3a2..9dae0e2 100644
--- a/lib/dynflow/action/with_bulk_sub_plans.rb
+++ b/lib/dynflow/action/with_bulk_sub_plans.rb
@@ -9,6 +9,17 @@ module Dynflow
raise NotImplementedError
end
+ PlanNextBatch = Algebrick.atom
+
+ def run(event = nil)
+ if event === PlanNextBatch
+ spawn_plans if can_spawn_next_batch?
+ suspend
+ else
+ super
+ end
+ end
+
# Should return the expected total count of tasks
def total_count
raise NotImplementedError
@@ -40,13 +51,10 @@ module Dynflow
end
end
- def try_to_finish
- # Start next batch if we can, try to finish otherwise
- if can_spawn_next_batch?
- spawn_plans
- else
- super
- end
+ def spawn_plans
+ super
+ ensure
+ suspended_action << PlanNextBatch
end
private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment