fix initwrite behaviour

with handlers, a parameter from the cfg file which is not the
first of parameters with the same handler were not written.
fix: write_<param> method is called for all parameters in
<module>.writeDict even if there is no poll entry.

with this fix, the write_<method> is called even when a parameter
is not polled.
This commit is contained in:
l_samenv
2020-09-25 11:19:17 +02:00
parent 587b170f6a
commit f7576cf541
4 changed files with 38 additions and 35 deletions

View File

@ -118,8 +118,10 @@ class Poller(PollerBase):
self._stopped = False
self.maxwait = 3600
self.name = name
self.modules = [] # used for writeInitParams only
def add_to_poller(self, module):
self.modules.append(module)
factors = self.DEFAULT_FACTORS.copy()
try:
factors[DYNAMIC] = module.fast_pollfactor
@ -227,11 +229,13 @@ class Poller(PollerBase):
# nothing to do (else we might call time.sleep(float('inf')) below
started_callback()
return
for module in self.modules:
module.writeInitParams()
# do all polls once and, at the same time, insert due info
for _, queue in sorted(self.queues.items()): # do SLOW polls first
for idx, (_, _, (_, module, pobj, pname, factor)) in enumerate(queue):
lastdue = time.time()
module.writeOrPoll(pname)
module.pollOneParam(pname)
due = lastdue + min(self.maxwait, module.pollinterval * factor)
# in python 3 comparing tuples need some care, as not all objects
# are comparable. Inserting a unique idx solves the problem.