Skip to content

Commit 67c6cf3

Browse files
author
Gabriel Monroy
committed
rework subtask batching again
1 parent 08ae187 commit 67c6cf3

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

api/models.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,14 @@ def destroy(self):
439439
tasks = [ layer.destroy(async=True) for layer in all_layers ]
440440
node_tasks, layer_tasks = [], []
441441
for n, l in tasks:
442-
node_tasks.append(n), layer_tasks.append(l)
442+
node_tasks.extend(n), layer_tasks.extend(l)
443443
# kill all the nodes in parallel
444-
group(*node_tasks).apply_async().join()
444+
group(node_tasks).apply_async().join()
445445
# kill all the layers in parallel
446-
group(*layer_tasks).apply_async().join()
446+
group(layer_tasks).apply_async().join()
447447
# call a celery task to update the formation data bag
448448
if settings.CHEF_ENABLED:
449-
controller.destroy_formation.delay(self.id).wait() # @UndefinedVariable
449+
group([controller.destroy_formation.subtask()]).join() # @UndefinedVariable
450450

451451

452452
@python_2_unicode_compatible
@@ -491,18 +491,17 @@ def build(self, *args, **kwargs):
491491
def destroy(self, async=False):
492492
tasks = import_tasks(self.flavor.provider.type)
493493
# create subtasks to terminate all nodes in parallel
494-
node_tasks = [node.terminate(async=True) for node in self.node_set.all()]
495-
node_tasks = group(*node_tasks)
494+
node_tasks = [ node.destroy(async=True) for node in self.node_set.all() ]
496495
# purge other hosting provider infrastructure
497496
name = "{0}-{1}".format(self.formation.id, self.id)
498497
args = (name, self.flavor.provider.creds.copy(),
499498
self.flavor.params.copy())
500-
layer_tasks = group(*[tasks.destroy_layer.subtask(args)])
499+
layer_tasks = [ tasks.destroy_layer.subtask(args) ]
501500
if async:
502501
return node_tasks, layer_tasks
503502
# destroy nodes, then the layer
504-
node_tasks.apply_async().join()
505-
layer_tasks.apply_async().join()
503+
group(node_tasks).apply_async().join()
504+
group(layer_tasks).apply_async().join()
506505

507506

508507
@python_2_unicode_compatible

0 commit comments

Comments
 (0)