Skip to content

Port Value Management Updates - #215

Merged
ccrisan merged 11 commits into
mainfrom
value-management-updates
Aug 18, 2026
Merged

Port Value Management Updates#215
ccrisan merged 11 commits into
mainfrom
value-management-updates

Conversation

@ccrisan

@ccrisan ccrisan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

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 updates qToggleServer’s port value-writing pipeline by introducing an explicit write queue (with optional completion futures), adding clearer “target value” semantics for expression-driven writes, and adjusting the HTTP API write endpoint to route writes through the queue rather than writing directly.

Changes:

  • Add WriteRequest + queued write helpers (push_write, push_write_and_wait) and use get_target_value() to avoid redundant queued writes.
  • Switch port sequences to enqueue writes (instead of fire-and-forget direct writes) and extend Sequence to support forwarding extra callback args/kwargs.
  • Remove the APIAccepted (202) pathway and update patch_port_value to wait for queued writes to complete.

Reviewed changes

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

Show a summary per file
File Description
tests/unit/qtoggleserver/utils/test_sequence.py Adds unit tests for Sequence behavior, including callback argument forwarding and cancellation/repeat behavior.
tests/unit/qtoggleserver/core/test_ports.py Adds/updates tests for new target-value logic, queued writes, persistence write_queue, and legacy persisted value behavior.
tests/unit/qtoggleserver/core/api/test_funcs_ports.py Adds tests ensuring PATCH /ports/{id}/value routes through push_write_and_wait and maps write errors to API errors.
qtoggleserver/web/base.py Removes web-layer handling for the removed APIAccepted exception.
qtoggleserver/utils/sequence.py Extends Sequence to forward callback args/kwargs to its callback.
qtoggleserver/core/ports.py Introduces WriteRequest, write queue semantics, get_target_value(), persistence format change to write_queue, and sequence writes via queue.
qtoggleserver/core/api/funcs/ports.py Updates patch_port_value to queue + wait for writes instead of calling transform_and_write_value directly.
Suppressed comments (2)

tests/unit/qtoggleserver/core/test_ports.py:174

  • Same asyncio.get_event_loop().create_future() concern here: inside an async test it should use asyncio.get_running_loop() to avoid deprecation/behavior changes on Python >= 3.14.
        mocker.patch.object(mock_num_port1, "transform_and_write_value", new=blocking_transform)

        future_a = asyncio.get_event_loop().create_future()
        future_b = asyncio.get_event_loop().create_future()
        mock_num_port1.push_write(1, future=future_a)
        mock_num_port1.push_write(2, future=future_b)

tests/unit/qtoggleserver/core/test_ports.py:121

  • This test also uses asyncio.get_event_loop().create_future(). Since tests are running on Python >= 3.14, prefer asyncio.get_running_loop().create_future() inside async tests.
        mocker.patch.object(mock_num_port1, "save_asap")
        mock_num_port1._write_queue.clear()
        evicted_future = asyncio.get_event_loop().create_future()
        mock_num_port1.push_write(1, future=evicted_future)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread qtoggleserver/core/ports.py
Comment thread qtoggleserver/core/api/funcs/ports.py Outdated
Comment thread tests/unit/qtoggleserver/core/test_ports.py
@ccrisan
ccrisan merged commit 975722b into main Aug 18, 2026
3 checks passed
@ccrisan
ccrisan deleted the value-management-updates branch August 18, 2026 10:38
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