-
Notifications
You must be signed in to change notification settings - Fork 38
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
fix: threadsafe waiting queue #301
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from .. import CommandVacuumError, DeviceData, RoborockCommand, RoborockException | ||
from ..exceptions import VacuumError | ||
from ..protocol import MessageParser | ||
from ..roborock_future import RequestKey | ||
from ..roborock_message import MessageRetry, RoborockMessage, RoborockMessageProtocol | ||
from ..util import RoborockLoggerAdapter | ||
from .roborock_client_v1 import COMMANDS_SECURED, RoborockClientV1 | ||
|
@@ -54,15 +55,19 @@ async def send_message(self, roborock_message: RoborockMessage): | |
response_protocol = request_id + 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this trying to set the response protocol to the next thing, e.g. HELLO_REQUEST to HELLO_RESPONSE? I think it ends up munging things up and i can't tell what this is trying to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK great, maybe i can figure out another way to use the new protocol types. I'll think about this more and maybe: |
||
else: | ||
request_id = roborock_message.get_request_id() | ||
_LOGGER.debug("Getting next request id: %s", request_id) | ||
response_protocol = RoborockMessageProtocol.GENERAL_REQUEST | ||
if request_id is None: | ||
raise RoborockException(f"Failed build message {roborock_message}") | ||
local_key = self.device_info.device.local_key | ||
msg = MessageParser.build(roborock_message, local_key=local_key) | ||
request_key = RequestKey(request_id, response_protocol) | ||
if method: | ||
self._logger.debug(f"id={request_id} Requesting method {method} with {params}") | ||
self._logger.debug(f"id={request_key} Requesting method {method} with {params}") | ||
else: | ||
self._logger.debug(f"id={request_key} Requesting with {params}") | ||
# Send the command to the Roborock device | ||
async_response = self._async_response(request_id, response_protocol) | ||
async_response = self._async_response(request_key) | ||
self._send_msg_raw(msg) | ||
diagnostic_key = method if method is not None else "unknown" | ||
try: | ||
|
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.
Maybe this should be a subclass of RoborockException for easier error handling?
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.
My thinking is that if this happens its a bug/shouldn't happen case and so it shouldn't be treated like a server side error. My thinking is: what do we expect a caller to do to handle this?