-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Keep task references while running #87970
Conversation
while self._pending_tasks: | ||
pending = [task for task in self._pending_tasks if not task.done()] | ||
self._pending_tasks.clear() |
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.
The old approach would clear all the tasks so it would only track new tasks. The new approach is to just track all tasks. Old + new. It doesn't matter because if the old one blocks, it's also blocking. It was also necessary because each task will try to remove itself from this set once it's done.
Tried re-running the failed tests locally and they all pass 🙄
|
de389a4
to
e642fb4
Compare
@@ -69,7 +69,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: | |||
else: | |||
_LOGGER.debug("No connection check for UDP possible") | |||
|
|||
GraphiteFeeder(hass, host, port, protocol, prefix) | |||
hass.data[DOMAIN] = GraphiteFeeder(hass, host, port, protocol, prefix) |
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 is this changed?
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.
Previously the test relied on race conditions about when the thread was done with work. Now the test just wait for the thread to be done.
fb704b0
to
6fe9569
Compare
Testing
|
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.
Testing looks good 👍
Breaking change
Proposed change
Attempt 2 to make sure we track all tasks created in HA. This time we only track it for tasks created via
hass.async_create_task
and not for all tasks created on our event loop (which was attempt 1 at #87959)Will always track tasks but make sure tasks clean up themselves.
This feels a bit like heart surgery…
Also added a newhass.background_task.async_create_task
for tasks you know are going to be in the background. They will never blockasync_block_till_done
but still get canceled when HA shuts down.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: