Skip to content

Improve action queue code quality#2019

Merged
iMicknl merged 5 commits intov2/mainfrom
v2/action_queue_improvements
Apr 25, 2026
Merged

Improve action queue code quality#2019
iMicknl merged 5 commits intov2/mainfrom
v2/action_queue_improvements

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 25, 2026

No description provided.

iMicknl added 4 commits April 25, 2026 20:11
…ush, fix shutdown lock

- Extract _merge_actions() helper to deduplicate action-merging logic in add()
- Replace hand-rolled snapshot in _delayed_flush with _prepare_flush() call
- Move cancelled task await outside lock in shutdown() to prevent potential deadlock
… efficiency; add tests for ActionQueueSettings validation and handling of empty actions.
@iMicknl iMicknl marked this pull request as ready for review April 25, 2026 19:25
@iMicknl iMicknl requested a review from tetienne as a code owner April 25, 2026 19:25
Copilot AI review requested due to automatic review settings April 25, 2026 19:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the action queue batching implementation to reduce duplication, clarifies queue behavior in docs, and adds tests to cover validation and edge cases around flushing/cancellation.

Changes:

  • Refactor action merging into a shared helper and simplify batch execution unpacking.
  • Adjust delayed-flush / shutdown flow to avoid self-cancellation and reduce lock-held awaits.
  • Add tests for settings validation, empty add/flush/shutdown behavior, and cancellation propagation; expand action-queue documentation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pyoverkiz/action_queue.py Refactors action merging and adjusts delayed flush/shutdown logic; expands class docstring explanation.
tests/test_action_queue.py Adds new tests covering settings validation, empty inputs, cancellation propagation, and delayed-flush self-cancel regression.
docs/action-queue.md Adds detailed explanation and examples of batching/merging behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyoverkiz/action_queue.py Outdated
Comment thread pyoverkiz/action_queue.py Outdated
Comment thread docs/action-queue.md Outdated
Comment on lines +21 to +23
await client.execute_action_group([Action("io://1234-5678-1234/12345678", [Command(name=OverkizCommand.CLOSE)])])
await client.execute_action_group([Action("io://1234-5678-1234/87654321", [Command(name=OverkizCommand.OPEN)])])
await client.execute_action_group([Action("io://1234-5678-1234/11111111", [Command(name=OverkizCommand.STOP)])])
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

This example constructs Action positionally (Action("io://...", [...])), but pyoverkiz.models.Action is kw_only=True, so positional args will raise TypeError. Update to Action(device_url=..., commands=[...]).

Copilot uses AI. Check for mistakes.
Comment thread docs/action-queue.md Outdated
Comment thread docs/action-queue.md Outdated
@iMicknl iMicknl merged commit 8e18390 into v2/main Apr 25, 2026
8 checks passed
@iMicknl iMicknl deleted the v2/action_queue_improvements branch April 25, 2026 19:37
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.

2 participants