-
Notifications
You must be signed in to change notification settings - Fork 57
fix: Ensure immediate local connection is attempted #640
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,14 +82,16 @@ async def discover_devices(self) -> list[RoborockDevice]: | |||||
|
|
||||||
| # These are connected serially to avoid overwhelming the MQTT broker | ||||||
| new_devices = {} | ||||||
| start_tasks = [] | ||||||
| for duid, (device, product) in device_products.items(): | ||||||
| if duid in self._devices: | ||||||
| continue | ||||||
| new_device = self._device_creator(home_data, device, product) | ||||||
| new_device.start_connect() | ||||||
| start_tasks.append(new_device.start_connect()) | ||||||
| new_devices[duid] = new_device | ||||||
|
|
||||||
| self._devices.update(new_devices) | ||||||
| await asyncio.gather(*start_tasks) | ||||||
|
||||||
| await asyncio.gather(*start_tasks) | |
| await asyncio.gather(*start_tasks, return_exceptions=True) |
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.
This comment is now misleading. The code previously connected devices serially, but with the changes in this PR, devices now start connecting in parallel (via
asyncio.gather()on line 94). The comment should be updated to reflect the new behavior, or removed if parallel connection is the intended behavior.If overwhelming the MQTT broker is still a concern, consider updating the comment to explain why parallel connection is now acceptable, or implement a mechanism to limit concurrency (e.g., using a semaphore).