Skip to content
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

Request the minimum of limit and batch_size. #165

Merged
merged 1 commit into from
Jun 16, 2017
Merged

Conversation

pcostell
Copy link
Contributor

Addresses #164 by setting the batch_size on each request to the min of the limit and the batch_size.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 87.605% when pulling f83896d on pcostell:master into e8f92c9 on google:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 87.605% when pulling 58aea88 on pcostell:master into e8f92c9 on google:master.

Copy link
Contributor

@vilasj vilasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, was this causing problems on the server side? If so, seems like this check should be made there as well?

setattr(request, current_token_attribute, None)
while limit is None or limit:
if batch_size_attribute:
request_batch_size = min(batch_size,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request_batch_size = min(batch_size, limit or batch_size) ?

This prevents YieldFromList from requesting more resources than
originally requested by the caller.
@pcostell
Copy link
Contributor Author

The server side only receives a single "page_size". In the case of our API, we just noticed this due to some bad test data further down in the list. For some APIs, List costs money per result returned, so I believe this is good in general.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 87.605% when pulling 47e2abe on pcostell:master into e8f92c9 on google:master.

@vilasj vilasj merged commit c91a86d into google:master Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants