diff --git a/connectors.py b/connectors.py index 9a5d345..99ee2f3 100644 --- a/connectors.py +++ b/connectors.py @@ -35,13 +35,12 @@ class Cache: timestamp = datetime.now().timestamp() # clear old data - for cache_data in self.CACHE_DATA: - for connector_class in cache_data: - for connector_func in connector_class: - for connector_query in connector_func: - for connector_page in connector_query: - if connector_page['timeout'] < timestamp: - del connector_query + for connector_class in list(self.CACHE_DATA): + for connector_func in list(self.CACHE_DATA[connector_class]): + for connector_query in list(self.CACHE_DATA[connector_class][connector_func]): + for connector_page in list(self.CACHE_DATA[connector_class][connector_func][connector_query]): + if self.CACHE_DATA[connector_class][connector_func][connector_query][connector_page]['timeout'] < timestamp: + del self.CACHE_DATA[connector_class][connector_func][connector_query][connector_page] if connector.__class__.__name__ not in self.CACHE_DATA: self.CACHE_DATA[connector.__class__.__name__] = {}