-
Notifications
You must be signed in to change notification settings - Fork 2
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVEXP-733: Refactor Token Paginator #47
DEVEXP-733: Refactor Token Paginator #47
Conversation
|
||
list_response = token_based_paginator.get_content() | ||
active_numbers_list = [num.phone_number for num in token_based_paginator.iterator()] |
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.
The TokenBasedPaginator
is a custom iterator that lazily retrieves one item at a time. However, when wrapped with list()
or [ ]
, Python fully consumes the iterator, loading all items into memory at once
To prevent excessive memory usage, you should use lazy iteration with while
or for
loops instead.
While the current tests handle small data, this practice should be avoided in real-world scenarios. Proper examples and a quickstart guide will be provided soon. However, users exploring the unit tests for reference should not be encouraged to use list()
.
async for _ in async_token_based_paginator.iterator(): | ||
number_counter += 1 | ||
active_numbers_list = [ | ||
num.phone_number async for num in async_token_based_paginator.iterator() |
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.
same here
"PagedResponse", ["result", "has_next_page", "next_page_info", "next_page"] | ||
) | ||
|
||
next_page_info = { |
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.
Shouldn't we keep this info?
Information reported in the initial PR by @matsk-sinch . Closing this one |
@matsk-sinch : Proposal to simplify the implementation and usage of the token paginator