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

Conversation

jimwbaldwin
Copy link

Rationale

The talk incremental export currently gets stuck in an infinite loop when as the next() BaseResultGenerator cannot handle however the Zendesk API is returning the data for talk incremental.

Issue: #489

This PR is to hopefully address that issue.

Changes

  • Added an internal iteration counter to the BaseResultGenerator
  • Added a count attribute to BaseResultGenerator which will either be the count of rows returned or None depending on if the API returns the count key.
  • Added a check for the iteration counter is greater than the count. If it is then it raises a StopIteration exception and ends the loop.

Testing

  • I have run the tests via the Makefile and everything passes.

image

- I have manually tested calling the talk API and it now returns my data without getting stuck in a loop.

@jimwbaldwin
Copy link
Author

Let me know if any feedback on this, happy to fix it up if there are problems.

@cryptomail
Copy link
Collaborator

I do NOT want to just let the lie fallow. @Ptr314 Let's have a look.
I appreciate all the work you did on this. I'll coordinate and see if we can get this merged ASAP.

@cryptomail
Copy link
Collaborator

I do want to ensure there's a test for this @jimwbaldwin .... I'd like to at least reproduce the bug in some form first at the very least.

@jimwbaldwin
Copy link
Author

@cryptomail No rush on my end to get it in. I coded the fix into my project but I'd love to remove that.

If I recall correctly it was when there was a low number of results. So maybe if we can code a test to pull back just a few rows.

I can take a look at the tests next week though it might take me a bit to figure them out.

@@ -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.

@cryptomail
Copy link
Collaborator

@cryptomail No rush on my end to get it in. I coded the fix into my project but I'd love to remove that.

If I recall correctly it was when there was a low number of results. So maybe if we can code a test to pull back just a few rows.

I can take a look at the tests next week though it might take me a bit to figure them out.

THANK YOU SO MUCH!!!!

@jimwbaldwin jimwbaldwin marked this pull request as draft October 10, 2023 21:38
@jimwbaldwin
Copy link
Author

Just set it to a draft as it isn't ready.

@jimwbaldwin jimwbaldwin closed this by deleting the head repository Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants