-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Shutdown database engine before waiting for executor shutdown #117339
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4a15189
Close database connection before stopping the executor
bdraco 766b39a
Close database connection before waiting for database executor to finish
bdraco 23fad7e
fix test
bdraco a749e74
fix
bdraco 2787c79
Merge branch 'dev' into executor_shutdown
bdraco d2ada37
Merge branch 'dev' into executor_shutdown
bdraco d7f4492
Merge branch 'dev' into executor_shutdown
bdraco 83fdac6
Merge branch 'dev' into executor_shutdown
bdraco 8a9fe6a
drop unused arg
bdraco afab10f
Revert "drop unused arg"
bdraco 25a7c1e
docstring
bdraco de1da58
comment
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 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 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 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
Oops, something went wrong.
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 do we need the
join_threads_or_timeout
argument?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 don't think we do. Not sure if we ever did.
dropped in 8a9fe6a
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.
nope it breaks because we need to wait to join https://github.com/home-assistant/core/pull/117339/files#diff-909bb3e2ee175002975532b69a04af5a78fd77c6ca3259f3848b7c1e0678cba1R1498 for the recorder case as we want the connection closed before we join but not for the default executor shutdown case
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.
Can you explain this a bit more? Who's calling this function in the default shutdown case?
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.
shutdown
gets called from https://github.com/python/cpython/blob/8edfa0b0b4ae4235bb3262d952c23e7581516d4f/Lib/asyncio/base_events.py#L606 viacore/homeassistant/runner.py
Line 194 in 47beddc
We want database executor to gracefully close the connection before it can reach the code that would forcefully interrupt the threads that fail to join gracefully. For the default executor we don't need to do that (current behavior) since there isn't a way to gracefully shut them down if they don't join on their own.
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.
OK, I see. Please amend the docstring to explain this, and also explain when calling
shutdown
withjoin_threads_or_timeout=False
why we do thatThere 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.
Adjusted the docstring and added some more comments