-
Notifications
You must be signed in to change notification settings - Fork 116
Stop a closed PolarsDataFrameIterator for every reader kind #1029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,8 +121,10 @@ def close(self) -> None: | |
| """Close the iterator and release resources.""" | ||
| from types import GeneratorType | ||
|
|
||
| if isinstance(self._reader, GeneratorType): | ||
| self._reader.close() | ||
| reader = self._reader | ||
| self._reader = iter(()) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round two (claims, callers, operations): CLEAN Base
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent review (relayed): CLEAN Reviewer: Codex CLI 0.160.0, model Covered (reviewer): both reader kinds; Pre-existing boundaries noted by the reviewer, not changed:
|
||
| if isinstance(reader, GeneratorType): | ||
| reader.close() | ||
|
|
||
| def iterrows(self) -> Iterator[tuple[int, dict[str, Any]]]: | ||
| """Iterate over rows as (index, row_dict) tuples. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review round one (implementation behavior): CLEAN
Base
de8cc52ac2a43cdba72bb4571c185883287741fc, headc7846e619459926f07cb5db6c1a342658bea2f54.Covered:
PolarsDataFrameIterator.close(),__next__()(which callsclose()onStopIteration),__exit__,iterrows(), and the callersAthenaPolarsResultSet.close()anditer_chunks()(whole-DataFrame and chunk-generator readers).close(), the reader isiter(()), so iteration ends and theiter([df])list iterator (with the DataFrame) is released.GeneratorExitat itsyield;_iter_*_chunkscatches onlyException), and the reader isiter(())instead of the closed generator. Both end iteration the same way.close()andclose()from__next__after exhaustion are no-ops.dataframereader. Thegeneratorcase guards the existing behavior.