Skip to content

Commit 128d7e8

Browse files
committed
Correct iter_items
1 parent d66a2ef commit 128d7e8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

quixstreams/state/rocksdb/partition.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,17 @@ def iter_items(
174174

175175
if not backwards:
176176
# NOTE: Forward iteration respects bounds correctly.
177-
return items
177+
# Also, we need to use yield from notation to replace RdictItems
178+
# with Python-native generator or else garbage collection
179+
# will make the result unpredictable.
180+
yield from items
178181
else:
179182
# NOTE: When iterating backwards, the `read_opt` lower bound
180183
# is not respected by Rdict for some reason. We need to manually
181184
# filter it here.
182-
return ((key, value) for key, value in items if lower_bound <= key)
185+
for key, value in items:
186+
if lower_bound <= key:
187+
yield (key, value)
183188

184189
def exists(self, key: bytes, cf_name: str = "default") -> bool:
185190
"""

0 commit comments

Comments
 (0)