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

fix incorrect back-off factor update in dash.py #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zjx20
Copy link

@zjx20 zjx20 commented Jul 28, 2024

No description provided.

@ImAleeexx
Copy link
Owner

Why should the back off factor be capped at 10 ?

@zjx20
Copy link
Author

zjx20 commented Jul 29, 2024

I should have explained this. Please notice that the back_off_factor variable isn't the actual sleep time, it's a factor.

Let's simply the logic.

back_off_factor = 1
while not closed:
    refresh_wait = 5 # although it could be something else, let's assume that it is 5
    with self.sleeper(refresh_wait * back_off_factor):
        ...
        if not self.reload():
            back_off_factor = max(back_off_factor * 1.3, 10.0)
        else:
            back_off_factor = 1

Suppose self.reload() returns False 5 times in a row, and the values of back_off_factor are 1, 10, 13, 16.9, 21.97, 28.561. The actual sleep times refresh_wait * back_off_factor are 5s, 50s, 65s, 84.5s, 109.85s, 142.805s.
But if we change the max() to min(), the back_off_factor sequence is 1, 1.3, 1.69, 2.197, 2.8561, 3.71293. And the actual sleep time sequence is 5s, 6.5s, 8.45s, 10.985s, 14.2805s, 18.56465.

I believe this is a logical error and min() should be the correct one, because a 10 times longer sleep time for the first failure makes no sense.

Why should the back off factor be capped at 10 ?

Since refresh_wait is the suggested refresh interval, 10 times refresh_wait should be large enough for backing-off.

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