You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(connector): forward stop_requested parameter from run_loop to _run_loop - #2544
Urgent main CI hotfix: restores packages / flow core lint (ruff, mypy) across all PRs.
Root Cause
When #2300 split run_loop(...) into run_loop(...) + _run_loop(...) for _stop_signals_interrupt(), run_loop(...) accepted stop_requested: Optional[threading.Event] = None (passed by windows_service.py:285), but did not forward stop_requested into _run_loop(...) or declare it on _run_loop's signature. As a result, line 455 (retry_stop = stop_requested if stop_requested is not None else stop) triggered two Ruff F821 undefined-name errors and would raise NameError at runtime when once=False.
Fix
Forward stop_requested=stop_requested from run_loop() to _run_loop() and add stop_requested: Optional[threading.Event] = None to _run_loop() in packages/flow/openadapt_flow/connector/daemon.py (+2 lines).
Verification
ruff check openadapt_flow/connector — passed
ruff format --check openadapt_flow/connector/daemon.py — passed
No per-app code in the engine: Yes — connector daemon lifecycle wiring only.
Fix the class, not the instance: Yes — completes the run_loop -> _run_loop parameter forwarding so every caller (including windows_service.py) gets cooperative stop signaling.
Held-out evidence: Not applicable — parameter-forwarding bug fix verified by the full 211-test connector suite.
The unique diff vs current main (c71d463de7821b898eb5367803ce5b45947ec7c6) is the two lines claimed: run_loop now forwards stop_requested=stop_requested into _run_loop, and _run_loop declares stop_requested: Optional[threading.Event] = None. That is the name _run_loop already reads at retry_stop = stop_requested if stop_requested is not None else stop (now line 457). On main that read is an F821 / runtime NameError whenever once=False.
This matches the Windows service caller, which already passes stop_requested=stop_event into run_loop. When that event is set, the poll loop exits, and the existing finally: stop.set() still stops the heartbeat thread and drains jobs. Callers that omit the argument keep the previous behavior (retry_stop is the local stop event). No app-specific engine change.
This is the straightforward fix for the #2300 split. I did not find a remaining unbound use of stop_requested.
Nit, not blocking this hotfix: there is still no regression test that run_loop(..., once=False, stop_requested=event) actually forwards the event and exits without a NameError. The existing connector tests did not catch the #2300 miss. Worth adding in a follow-up.
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
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.
Summary
Urgent
mainCI hotfix: restorespackages / flow core lint (ruff, mypy)across all PRs.Root Cause
When #2300 split
run_loop(...)intorun_loop(...)+_run_loop(...)for_stop_signals_interrupt(),run_loop(...)acceptedstop_requested: Optional[threading.Event] = None(passed bywindows_service.py:285), but did not forwardstop_requestedinto_run_loop(...)or declare it on_run_loop's signature. As a result, line 455 (retry_stop = stop_requested if stop_requested is not None else stop) triggered two RuffF821undefined-name errors and would raiseNameErrorat runtime whenonce=False.Fix
stop_requested=stop_requestedfromrun_loop()to_run_loop()and addstop_requested: Optional[threading.Event] = Noneto_run_loop()inpackages/flow/openadapt_flow/connector/daemon.py(+2 lines).Verification
ruff check openadapt_flow/connector— passedruff format --check openadapt_flow/connector/daemon.py— passedmypy openadapt_flow/connector/daemon.py— 0 issuespytest -q tests/test_connector*.py— 211 passed, 81 subtests passedGenerality & Durability
run_loop->_run_loopparameter forwarding so every caller (includingwindows_service.py) gets cooperative stop signaling.