From c39bca7db7e0e303ba381b9c0ac4a2c3faf62499 Mon Sep 17 00:00:00 2001 From: Jason Peacock Date: Fri, 13 Sep 2024 14:11:31 -0500 Subject: [PATCH] Convert generators into lists before sending over the network. ZEN-35062 --- Products/ZenCollector/services/ConfigCache.py | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Products/ZenCollector/services/ConfigCache.py b/Products/ZenCollector/services/ConfigCache.py index 8dedded71d..02005cd13d 100644 --- a/Products/ZenCollector/services/ConfigCache.py +++ b/Products/ZenCollector/services/ConfigCache.py @@ -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), } @@ -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):