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

zenpy-489 resolve talk calls infinite loop issue #540

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions zenpy/lib/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class BaseResultGenerator(Iterable):
def __init__(self, response_handler, response_json):
self.response_handler = response_handler
self._response_json = response_json
self.count = response_json.get("count")
self.values = None
self.position = 0
self._iteration = 0
self.update_attrs()
self._has_sliced = False
self.next_page_attr = 'next_page'
Expand All @@ -47,7 +49,10 @@ def next(self):
self.handle_pagination()
if len(self.values) < 1:
raise StopIteration()
if self.count is not None and self._iteration > self.count:
raise StopIteration()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't disagree with this as a halting condition as long as this count doesn't change :)

Copy link
Collaborator

@cryptomail cryptomail Sep 2, 2023

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I think I probably need to rework this, I was able to get some time to try a large extract from Talk and the count is per page, so if there was 1234 rows it was showing as 1000, then 234 on the next page. I was unable to use Zenpy directly because of this issue but yeah I don't think my fix is ready.

Apologies been swamped the last month but hopefully I get a bit to wrap this up.

zenpy_object = self.values[self.position]
self._iteration += 1
self.position += 1
return zenpy_object

Expand Down