From 1039bbe19fd5273ad152a587e3fed9783ded8947 Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Thu, 19 Dec 2024 13:32:17 -0500 Subject: [PATCH] CASMCMS-9225: Do not use itertools.batched, because it is not available in this Python version --- CHANGELOG.md | 4 ++++ src/bos/server/redis_db_utils.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c531e8b..a07406b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.10.30] - 2024-12-19 +### Fixed +- Do not use `itertools.batched`, because it is not available in this Python version. + ## [2.10.29] - 2024-12-18 ### Changed - Improve performance of large `GET` components requests. diff --git a/src/bos/server/redis_db_utils.py b/src/bos/server/redis_db_utils.py index 983c49c3..ecb87c5b 100644 --- a/src/bos/server/redis_db_utils.py +++ b/src/bos/server/redis_db_utils.py @@ -21,7 +21,6 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # -from itertools import batched import functools import json import logging @@ -110,9 +109,11 @@ def iter_values(self): """ Iterate through every item in the database. Parse each item as JSON and yield it. """ - for next_keys in batched(self.client.scan_iter(), 500): - for datastr in self.client.mget(next_keys): + all_keys = list(self.client.scan_iter()) + while all_keys: + for datastr in self.client.mget(all_keys[:500]): yield json.loads(datastr) if datastr else None + all_keys = all_keys[500:] def get_keys(self): """Get an array of all keys"""