fix(flows/actions): set _ongoing_actions_finished_event at ActionManager init - #4959
Open
Maurotb wants to merge 1 commit into
Open
fix(flows/actions): set _ongoing_actions_finished_event at ActionManager init#4959Maurotb wants to merge 1 commit into
Maurotb wants to merge 1 commit into
Conversation
…ger init The event indicates "no ongoing actions still running" and is guarded by the invariant `_ongoing_actions_count == 0 ↔ event set`. At construction `_ongoing_actions_count = 0` — so the event should already be set. Without an explicit `.set()` in `__init__`, an `await event.wait()` invoked before the first `_enqueue_action` call blocks indefinitely. Re-files pipecat-ai/pipecat-flows#287 against the new `pipecat.flows` submodule location (the standalone `pipecat-ai-flows` package was frozen in 1.4.0).
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
ActionManager._ongoing_actions_finished_eventis created as anasyncio.Event()at__init__and left unset, but the accompanying_ongoing_actions_countstarts at0. The event is guarded by the invariant "no ongoing actions are still running", i.e.count == 0 ↔ event set. At construction the count-side of the invariant is already satisfied, so the event should be set too.Without the initial
.set(), anawait self._ongoing_actions_finished_event.wait()invoked BEFORE the first_enqueue_actioncall blocks indefinitely, breaking the invariant and any caller (e.g. teardown, or aFlowManagerthat awaits the event during_set_node) that relies on it at startup.Fix
Call
.set()immediately after creating the event inActionManager.__init__.Test
Adds
test_ongoing_actions_finished_event_set_at_initintests/test_flows_actions.pythat asserts both_ongoing_actions_count == 0and_ongoing_actions_finished_event.is_set()right after construction.Compatibility
Purely additive — one method call in
__init__, no public API change, no behavior change for callers that already interact with the event AFTER at least one action has been enqueued (which is the common path).History
Re-files pipecat-ai/pipecat-flows#287 against the new
pipecat.flowssubmodule location. The standalonepipecat-ai-flowspackage was deprecated / frozen in 1.4.0 in favor of the first-partypipecat.flowsmodule insidepipecat-ai, so the original PR no longer targets a live branch.