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

Ensure polling thread is resilient to errors and exceptions #60

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

goncalossilva
Copy link
Contributor

Flagsmith's polling thread is not resilient to API errors. If for whatever reason the API response isn't a 200, FlagsmithAPIError is thrown and never caught, leaving the SDK running with a dead a polling thread and consequently stale data, even if the source of the error is addressed in the meantime.

Note: There are many ways to bake resiliency into this. This made the most sense to me, but you are welcome to tweak the existing code as you see fit.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Thanks @goncalossilva, this looks great. I've added one minor comment requesting another test case but otherwise, all good from me.

tests/test_polling_manager.py Outdated Show resolved Hide resolved
@goncalossilva
Copy link
Contributor Author

@matthewelwell Thanks for the quick review! Added handling for RequestException, take a look.

@goncalossilva goncalossilva changed the title Ensure polling thread is resilient to API errors Ensure polling thread is resilient to errors and exceptions Sep 7, 2023
flagsmith/polling_manager.py Outdated Show resolved Hide resolved
tests/test_polling_manager.py Outdated Show resolved Hide resolved
Co-authored-by: Kim Gustyr <khvn26@gmail.com>
tests/test_polling_manager.py Outdated Show resolved Hide resolved
Co-authored-by: Kim Gustyr <khvn26@gmail.com>
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@PotHix
Copy link

PotHix commented Sep 13, 2023

@matthewelwell @khvn26 all requested changes were applied. Should we merge this? :)

@khvn26 khvn26 dismissed matthewelwell’s stale review September 13, 2023 16:33

The outstanding comment was addressed.

@khvn26 khvn26 merged commit 77c8c2d into Flagsmith:main Sep 13, 2023
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.

4 participants