-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Cancel config entry retry, platform retry, and polling at the stop event #49138
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
Merged
bdraco
merged 9 commits into
home-assistant:dev
from
bdraco:abort_setup_retry_on_stop_event
Apr 14, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a91568f
Cancel config entry and platform retry at the stop event
bdraco 1be73df
.. and stop polling
bdraco 6cd17ef
coverage
bdraco 7d89af9
coverage
bdraco d9059ba
coverage
bdraco 2586d3c
coverage
bdraco 9c15bde
move entity platform shutdown to be per component
bdraco 77de50a
fix
bdraco 1329d3f
Remove unreachable code
bdraco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,6 +174,18 @@ def async_create_setup_task() -> Coroutine: | |
|
|
||
| await self._async_setup_platform(async_create_setup_task) | ||
|
|
||
| async def async_shutdown(self) -> None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| """Call when Home Assistant is stopping.""" | ||
| self.async_cancel_retry_setup() | ||
| self.async_unsub_polling() | ||
|
|
||
| @callback | ||
| def async_cancel_retry_setup(self) -> None: | ||
| """Cancel retry setup.""" | ||
| if self._async_cancel_retry_setup is not None: | ||
| self._async_cancel_retry_setup() | ||
| self._async_cancel_retry_setup = None | ||
|
|
||
| async def async_setup_entry(self, config_entry: config_entries.ConfigEntry) -> bool: | ||
| """Set up the platform from a config entry.""" | ||
| # Store it so that we can save config entry ID in entity registry | ||
|
|
@@ -549,9 +561,7 @@ async def async_reset(self) -> None: | |
|
|
||
| This method must be run in the event loop. | ||
| """ | ||
| if self._async_cancel_retry_setup is not None: | ||
| self._async_cancel_retry_setup() | ||
| self._async_cancel_retry_setup = None | ||
| self.async_cancel_retry_setup() | ||
|
|
||
| if not self.entities: | ||
| return | ||
|
|
@@ -560,10 +570,15 @@ async def async_reset(self) -> None: | |
|
|
||
| await asyncio.gather(*tasks) | ||
|
|
||
| self.async_unsub_polling() | ||
| self._setup_complete = False | ||
|
|
||
| @callback | ||
| def async_unsub_polling(self) -> None: | ||
| """Stop polling.""" | ||
| if self._async_unsub_polling is not None: | ||
| self._async_unsub_polling() | ||
| self._async_unsub_polling = None | ||
| self._setup_complete = False | ||
|
|
||
| async def async_destroy(self) -> None: | ||
|
bdraco marked this conversation as resolved.
|
||
| """Destroy an entity platform. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why should this be a coroutine function? We don't await inside.
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.
I made it a coroutine because I figured we would need to add more to it later (#49241) and it would end up being a coroutine anyways which would be a breaking change in the api I wanted to avoid in the future.
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.
Sounds good!