Add log messages.
This commit is contained in:
parent
ca3a8ddf67
commit
e6b9fc90ba
1 changed files with 13 additions and 2 deletions
|
@ -279,6 +279,7 @@ class Config(object):
|
||||||
return objects_changed
|
return objects_changed
|
||||||
|
|
||||||
def _iterate_once_sequential(self):
|
def _iterate_once_sequential(self):
|
||||||
|
self.log.info("Iteration in sequential mode")
|
||||||
objects_changed = False
|
objects_changed = False
|
||||||
|
|
||||||
for cdist_object in self.object_list():
|
for cdist_object in self.object_list():
|
||||||
|
@ -305,6 +306,8 @@ class Config(object):
|
||||||
return objects_changed
|
return objects_changed
|
||||||
|
|
||||||
def _iterate_once_parallel(self):
|
def _iterate_once_parallel(self):
|
||||||
|
self.log.info("Iteration in parallel mode in {} jobs".format(
|
||||||
|
self.jobs))
|
||||||
objects_changed = False
|
objects_changed = False
|
||||||
|
|
||||||
cargo = []
|
cargo = []
|
||||||
|
@ -320,13 +323,17 @@ class Config(object):
|
||||||
# objects_changed = True
|
# objects_changed = True
|
||||||
cargo.append(cdist_object)
|
cargo.append(cdist_object)
|
||||||
|
|
||||||
if len(cargo) == 1:
|
n = len(cargo)
|
||||||
|
if n == 1:
|
||||||
|
self.log.debug("Only one object, preparing sequentially")
|
||||||
self.object_prepare(cargo[0])
|
self.object_prepare(cargo[0])
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
elif cargo:
|
elif cargo:
|
||||||
|
self.log.debug("Preparing {} objects in parallel".format(n))
|
||||||
with concurrent.futures.ProcessPoolExecutor(self.jobs) as executor:
|
with concurrent.futures.ProcessPoolExecutor(self.jobs) as executor:
|
||||||
for x in executor.map(self.object_prepare, cargo):
|
for x in executor.map(self.object_prepare, cargo):
|
||||||
pass # returns None
|
pass # returns None
|
||||||
|
self.log.debug("Preparation finished")
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
|
|
||||||
del cargo[:]
|
del cargo[:]
|
||||||
|
@ -347,13 +354,17 @@ class Config(object):
|
||||||
# objects_changed = True
|
# objects_changed = True
|
||||||
cargo.append(cdist_object)
|
cargo.append(cdist_object)
|
||||||
|
|
||||||
if len(cargo) == 1:
|
n = len(cargo)
|
||||||
|
if n == 1:
|
||||||
|
self.log.debug("Only one object, running sequentially")
|
||||||
self.object_run(cargo[0])
|
self.object_run(cargo[0])
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
elif cargo:
|
elif cargo:
|
||||||
|
self.log.debug("Running {} objects in parallel".format(n))
|
||||||
with concurrent.futures.ProcessPoolExecutor(self.jobs) as executor:
|
with concurrent.futures.ProcessPoolExecutor(self.jobs) as executor:
|
||||||
for x in executor.map(self.object_run, cargo):
|
for x in executor.map(self.object_run, cargo):
|
||||||
pass # returns None
|
pass # returns None
|
||||||
|
self.log.debug("Running finished")
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
|
|
||||||
return objects_changed
|
return objects_changed
|
||||||
|
|
Loading…
Reference in a new issue