mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-24 18:28:21 +00:00
Fix potential infinite loop if incomplete lists returned (#920)
Fixes the test framework to handle fixtures with incomplete lists better by checking for completeness and overriding the sum. Also adds a pytest-timeout dev dependency with timeout set to 10 seconds. Finally fixes smartprotocol to prevent an infinite loop if incomplete lists ever happens in the real world. Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
@@ -229,6 +229,13 @@ class SmartProtocol(BaseProtocol):
|
||||
iterate_list_pages=False,
|
||||
)
|
||||
next_batch = response[method]
|
||||
# In case the device returns empty lists avoid infinite looping
|
||||
if not next_batch[response_list_name]:
|
||||
_LOGGER.error(
|
||||
f"Device {self._host} returned empty "
|
||||
+ f"results list for method {method}"
|
||||
)
|
||||
break
|
||||
response_result[response_list_name].extend(next_batch[response_list_name])
|
||||
|
||||
def _handle_response_error_code(self, resp_dict: dict, method, raise_on_error=True):
|
||||
|
||||
Reference in New Issue
Block a user