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

Allow kwargs to throttled functions, await sleep in throttle #823

Merged
merged 9 commits into from
Dec 6, 2023

Conversation

mkmer
Copy link
Contributor

@mkmer mkmer commented Nov 22, 2023

Description:

Move back to .get() for throttle kwargs
Add time delay to actually "throttle" the call rather than "ignore" the call.

Related issue (if applicable): fixes #

Checklist:

  • Local tests with tox run successfully PR cannot be meged unless tests pass
  • Changes tested locally to ensure platform still works as intended
  • Tests added to verify new code works

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (32f3235) 99.86% compared to head (71facfb) 99.86%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #823      +/-   ##
==========================================
- Coverage   99.86%   99.86%   -0.01%     
==========================================
  Files           8        8              
  Lines        1454     1453       -1     
==========================================
- Hits         1452     1451       -1     
  Misses          2        2              
Flag Coverage Δ
unittests 99.86% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mkmer
Copy link
Contributor Author

mkmer commented Nov 22, 2023

Unfortunately, just adding kwargs and moving to .get() does not address the update issue due to the lower level API calls also being wrapped with @Throttle.

@mkmer mkmer mentioned this pull request Nov 22, 2023
3 tasks
@mkmer
Copy link
Contributor Author

mkmer commented Nov 22, 2023

OK - this appears to do the trick - The throttle waits the prescribed time then returns the function rather than None.
Now HA updates when we expect it to (sometimes just a bit slower due to throttles).
With this solution in place (or not), I still think we can remove the throttle from refresh() as the underlying homescreen() all is throttled.

@mkmer
Copy link
Contributor Author

mkmer commented Nov 29, 2023

Thoughts on this way to address the issue?

@fronzbot
Copy link
Owner

fronzbot commented Dec 5, 2023

@mkmer yeah I like this approach. I'm ready to merge unless you can think of a way to test the throttling- right now I think we could remove decorators and the test would still pass (but maybe I'm wrong- my mental model of all this is a bit hazy)

@fronzbot fronzbot merged commit a884161 into fronzbot:dev Dec 6, 2023
8 checks passed
@mkmer mkmer deleted the allow-kwargs-to-throttled-functions branch December 6, 2023 20:39
@mkmer
Copy link
Contributor Author

mkmer commented Dec 7, 2023

Could we do a release for this pr soon? It addresses slow responses to motion arm/disarm switch I recently added to HA. We missed 2023.12 but maybe I can get it in 2023.12.1.

@mkmer
Copy link
Contributor Author

mkmer commented Dec 15, 2023

Please? Maybe 2024.1

@fronzbot
Copy link
Owner

Yeah sorry, meant to get around to it last week but held off because I needed to test another PR before merging (and wanted to get that into a release as well) but, as usual, life laughed at me and kicked me in the 'nads

@fronzbot fronzbot mentioned this pull request Dec 18, 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.

2 participants