Skip to content

Commit

Permalink
Convert generators into lists before sending over the network.
Browse files Browse the repository at this point in the history
ZEN-35062
  • Loading branch information
jpeacock-zenoss committed Sep 13, 2024
1 parent 3ca4225 commit c39bca7
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 c39bca7

Please sign in to comment.