Speed up ZHA initialization and improve startup responsiveness (#108103)

* Limit concurrency of startup traffic to allow for interactive usage

* Drop `retryable_req`, we already have request retrying

* Oops, `min` -> `max`

* Add a comment describing why `async_initialize` is not concurrent

* Fix existing unit tests

* Break out fetching mains state into its own function to unit test
This commit is contained in:
puddly 2024-01-17 18:36:28 -05:00 committed by GitHub
parent 3ae858e3bf
commit 867caab70a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 151 additions and 84 deletions

View file

@ -135,7 +135,7 @@ def _wrap_mock_instance(obj: Any) -> MagicMock:
real_attr = getattr(obj, attr_name)
mock_attr = getattr(mock, attr_name)
if callable(real_attr):
if callable(real_attr) and not hasattr(real_attr, "__aenter__"):
mock_attr.side_effect = real_attr
else:
setattr(mock, attr_name, real_attr)