-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: Add simple retries on network errors #113
Conversation
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.
thanks! one (maybe dumb) question about how this works...
error = networkError; | ||
this.onNetworkError(this.progressBarElement, this.progressBarMessageElement, "Network Error"); | ||
attempts++; | ||
await new Promise(r => setTimeout(r, 1000)); |
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.
sorry my async JS is not so good. How does this end up doing a retry? like how does it know what to call again?
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.
My JS in general isnt great :D.
But it's just a while loop that try and catches in til the maxnetworkRetryAttempts are hit or if a request is successful.
while(!success && attempts < this.maxNetworkRetryAttempts) {
then runs the try {
catches the error and goes again
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.
Ah right, duh. And this is essentially the equivalent of an async sleep?
Edit: Looks like yes https://stackoverflow.com/a/39914235/8207
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.
Oh yes, this was just not to spam the backend with requests every miliseconds or so.
error = networkError; | ||
this.onNetworkError(this.progressBarElement, this.progressBarMessageElement, "Network Error"); | ||
attempts++; | ||
await new Promise(r => setTimeout(r, 1000)); |
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.
Ah right, duh. And this is essentially the equivalent of an async sleep?
Edit: Looks like yes https://stackoverflow.com/a/39914235/8207
@czue could we bump and release a new version to pypi? Thanks! |
Done! Sorry about the delay. https://github.com/czue/celery-progress/releases/tag/0.3 |
No description provided.