Fix session leaks, replace blocking threads with async tasks, add reauth - #542
Merged
rroller merged 3 commits intoMar 8, 2026
Merged
Conversation
Copy Dahua brand icons and logos from the home-assistant/brands repository into custom_components/dahua/brand/ so HACS validation no longer needs to fall back to the brands repository. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add brand assets for HACS validation
… reauth - Fix session leak in config_flow._test_credentials() by adding finally clause - Fix session leak on unload by calling coordinator.async_stop() which closes session - Fix != None to is not None in _close_session() - Replace DahuaEventThread/DahuaVtoEventThread with native async tasks - Replace threading.Timer in VTO client with loop.call_later() - Replace loop.stop() in VTO with disconnected future for clean reconnect - Fix swallowed exceptions in client.stream_events() (re-raise CancelledError) - Add reauthentication flow triggered on HTTP 401 during initialization - Delete thread.py (no longer needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
brianegge
force-pushed
the
fix/async-tasks-session-leaks-reauth
branch
from
February 28, 2026 11:14
5d4a5cc to
1ca36d7
Compare
Owner
|
Thank you! |
|
Hi Brian, rroller, thanks for updating. Unfortunately after updating to anything from 0.9.76 up, scanning an rfid tag crashes home assistant. Anything you could do about that perhaps? |
Contributor
Author
|
It's related to this change? Is there a stack trace or issue open? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
aiohttp.ClientSessionin config flow credential test (finally: await session.close()) and on integration unload (await coordinator.async_stop())DahuaEventThreadandDahuaVtoEventThread(andthread.pyentirely), replacing them with nativeasyncio.Taskcoroutines that run on HA's event loop. VTO client now usesloop.call_later()instead ofthreading.Timerand adisconnectedfuture instead ofloop.stop()client.stream_events()no longer silently catchesCancelledErroror swallows all exceptions with bareexcept: passTest plan
dahua_event_receivedevents🤖 Generated with Claude Code