Skip to content

Conversation

@alexrudd2
Copy link
Collaborator

A small simplification - return early in the broadcast case and don't bother with response.

(pyright had a false positive here, but it leads to simpler code)

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like simplification, but we must ensure never to send a response if we are in broadcast mode.

Seems there was also some CI problems.

self.server_send(response, self.last_addr)
response.transaction_id = self.last_pdu.transaction_id
response.dev_id = self.last_pdu.dev_id
self.server_send(response, self.last_addr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm seems to me this change will send a response if we are in broadcast mode, that is not allowed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is an early return in broadcast mode and this code will never execute.

context = self.server.context[self.last_pdu.dev_id]
response = await self.last_pdu.update_datastore(context)
await self.last_pdu.update_datastore(self.server.context[dev_id])
return
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broadcast mode returns here without responses

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with the old way ??? it seems more efficient to use asyncio.gather

@alexrudd2
Copy link
Collaborator Author

What was wrong with the old way ??? it seems more efficient to use asyncio.gather

I'm not sure, but it was causing the test failure so there must be some race condition? (My local pytest was fine...)

I can investigate in a separate PR.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is an explanation I can understand, and performance at this point is not very important (nor is your solution very slow).

@janiversen janiversen merged commit ea5d70d into dev Aug 8, 2025
1 check passed
@janiversen janiversen deleted the broadcast branch August 8, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants