Skip to content

Commit

Permalink
Merge pull request #4546 from zenoss/bugfix/ZEN-35062.6x
Browse files Browse the repository at this point in the history
Convert generators into lists before sending over the network.
  • Loading branch information
jpeacock-zenoss authored Sep 13, 2024
2 parents 3ca4225 + c39bca7 commit 7c51fea
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions Products/ZenCollector/services/ConfigCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,8 @@ def remote_getDeviceConfigs(
removed = previous - current

return {
"new": [
_get_configs(newest_keys, self._stores.device, self.log)
],
"updated": [
_get_configs(updated_keys, self._stores.device, self.log)
],
"new": list(self._get_configs(newest_keys)),
"updated": list(self._get_configs(updated_keys)),
"removed": list(removed),
}

Expand Down Expand Up @@ -194,24 +190,23 @@ def _filter(self, keys, predicate):
method = self.log.warn
method("error filtering device ID %s", key.device)


def _get_configs(keys, store, log):
if log.isEnabledFor(logging.DEBUG):
mlog = log.exception
else:
mlog = log.error
for key in keys:
try:
yield store.get(key).config
except Exception as ex:
mlog(
"failed to retrieve config "
"error=%s service=%s collector=%s device=%s",
ex,
key.service,
key.monitor,
key.device,
)
def _get_configs(self, keys):
if self.log.isEnabledFor(logging.DEBUG):
mlog = self.log.exception
else:
mlog = self.log.error
for key in keys:
try:
yield self._stores.device.get(key).config
except Exception as ex:
mlog(
"failed to retrieve config "
"error=%s service=%s collector=%s device=%s",
ex,
key.service,
key.monitor,
key.device,
)


class _DeviceProxy(object):
Expand Down

0 comments on commit 7c51fea

Please sign in to comment.