This repository was archived by the owner on Jul 5, 2026. It is now read-only.
fix(actions): set ActionManager finished-event at init to satisfy count=0 invariant - #287
Open
Maurotb wants to merge 1 commit into
Open
Conversation
``ActionManager.__init__`` set ``_ongoing_actions_count = 0`` and built ``_ongoing_actions_finished_event = asyncio.Event()``, which defaults to the clear state. This violates the natural invariant *count=0 ↔ event set*: an immediate ``await event.wait()`` blocks forever even though no action is in flight. The counter helpers (``_increment_ongoing_actions_count`` / ``_decrement_ongoing_actions_count``) flip the event correctly on transition, so the only buggy state was the initial one. Set the event at init time to restore the invariant; behaviour from the first action onward is unchanged. Reproducer: ``await ActionManager(worker, mgr)._ongoing_actions_finished_event.wait()`` hung forever pre-fix; returns immediately post-fix. Added a regression test pinning both ``count == 0`` and ``event.is_set()`` at init plus a ``wait_for(..., timeout=0.1)`` that exercises the path.
Maurotb
force-pushed
the
fix/action-manager-event-initial-state-invariant
branch
from
June 19, 2026 13:14
7ba5646 to
aa1baf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ActionManager.__init__set_ongoing_actions_count = 0then created_ongoing_actions_finished_event = asyncio.Event(), which defaults to clear. That violates the natural invariant count = 0 ↔ event set: with no action ever in flight, an immediateawait event.wait()blocks forever.The counter helpers (
_increment_ongoing_actions_count/_decrement_ongoing_actions_count) already flip the event correctly on transition, so the only buggy state was the initial one. Calling.set()at init restores the invariant; behaviour from the first action onward is unchanged.Repro (pre-fix hangs forever, post-fix returns immediately):
The added test (
test_ongoing_actions_finished_event_is_set_at_init) pins bothcount == 0andevent.is_set()at init, plus await_for(..., timeout=0.1)that exercises the wait path. Fails onmain, passes after the fix.Downstream context: we've been working around this with a small monkey-patch in our worker (
flows.ActionManager.__init__wrapped to call.set()after init) since shortly after picking up Flows. Switching to the fix on rebuild is a one-liner and would let us drop the patch.