Initial try for parallelization.
This commit is contained in:
parent
258a6c7f56
commit
1952d43073
1 changed files with 37 additions and 4 deletions
|
@ -267,11 +267,44 @@ class Config(object):
|
||||||
else:
|
else:
|
||||||
yield cdist_object
|
yield cdist_object
|
||||||
|
|
||||||
def iterate_once_parallel(self):
|
def iterate_once(self):
|
||||||
"""
|
"""
|
||||||
Iterate over the objects once - helper method for
|
Iterate over the objects once - helper method for
|
||||||
iterate_until_finished
|
iterate_until_finished
|
||||||
"""
|
"""
|
||||||
|
if self.jobs:
|
||||||
|
objects_changed = self._iterate_once_parallel()
|
||||||
|
else:
|
||||||
|
objects_changed = self._iterate_once_sequential()
|
||||||
|
return objects_changed
|
||||||
|
|
||||||
|
def _iterate_once_sequential(self):
|
||||||
|
objects_changed = False
|
||||||
|
|
||||||
|
for cdist_object in self.object_list():
|
||||||
|
if cdist_object.requirements_unfinished(cdist_object.requirements):
|
||||||
|
"""We cannot do anything for this poor object"""
|
||||||
|
continue
|
||||||
|
|
||||||
|
if cdist_object.state == core.CdistObject.STATE_UNDEF:
|
||||||
|
"""Prepare the virgin object"""
|
||||||
|
|
||||||
|
self.object_prepare(cdist_object)
|
||||||
|
objects_changed = True
|
||||||
|
|
||||||
|
if cdist_object.requirements_unfinished(cdist_object.autorequire):
|
||||||
|
"""The previous step created objects we depend on -
|
||||||
|
wait for them
|
||||||
|
"""
|
||||||
|
continue
|
||||||
|
|
||||||
|
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
||||||
|
self.object_run(cdist_object)
|
||||||
|
objects_changed = True
|
||||||
|
|
||||||
|
return objects_changed
|
||||||
|
|
||||||
|
def _iterate_once_parallel(self):
|
||||||
objects_changed = False
|
objects_changed = False
|
||||||
|
|
||||||
cargo = []
|
cargo = []
|
||||||
|
@ -300,7 +333,8 @@ class Config(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
||||||
if cdist_object.requirements_unfinished(cdist_object.autorequire):
|
if cdist_object.requirements_unfinished(
|
||||||
|
cdist_object.autorequire):
|
||||||
"""The previous step created objects we depend on -
|
"""The previous step created objects we depend on -
|
||||||
wait for them
|
wait for them
|
||||||
"""
|
"""
|
||||||
|
@ -327,8 +361,7 @@ class Config(object):
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
|
|
||||||
while objects_changed:
|
while objects_changed:
|
||||||
if self.jobs:
|
objects_changed = self.iterate_once()
|
||||||
objects_changed = self.iterate_once_parallel()
|
|
||||||
|
|
||||||
# Check whether all objects have been finished
|
# Check whether all objects have been finished
|
||||||
unfinished_objects = []
|
unfinished_objects = []
|
||||||
|
|
Loading…
Reference in a new issue