Skip to content

Reconnect inlet on settings change - #37

Merged
cboulay merged 1 commit into
devfrom
fix/inlet-reset-reconnect
Jul 8, 2026
Merged

Reconnect inlet on settings change#37
cboulay merged 1 commit into
devfrom
fix/inlet-reset-reconnect

Conversation

@cboulay

@cboulay cboulay commented Jul 8, 2026

Copy link
Copy Markdown
Member

Problem

Changing an LSLInletUnit's settings at runtime to target a different stream had no effect — the inlet kept pulling the originally-connected stream. Surfaced while wiring LSLInletUnit into a GUI where the user picks the stream from a menu after launch.

Root cause

LSLInletProducer._reset_state recreated the ContinuousResolver but left _state.inlet (and the derived msg_template / fetch_buffer / _warmed_up) pointing at the previous connection. update_settings_request_reset correctly forces the next __acall__ back through _reset_state, but _produce only calls _try_connect when _state.inlet is None, so it never re-resolved. In the irregular-rate case it was worse: the stale msg_template (a LinearAxis time axis) combined with the new settings' nominal_srate == 0 made _pull raise TypeError on replace(LinearAxis, data=…).

Fix

_reset_state now drops the existing inlet and its derived state before recreating the resolver, so the next _produce re-resolves and reconnects against the updated settings.

Test

Adds test_inlet_reconnect_on_settings_change: connects to an 8-channel stream, pushes settings targeting a 4-channel stream, and asserts the inlet reconnects (channel count flips 8 → 4). Verified it fails on the old _reset_state and passes on the new one; full test_inlet.py suite passes (6 tests).

🤖 Generated with Claude Code

`LSLInletProducer._reset_state` recreated the resolver but left
`_state.inlet` (and the derived `msg_template` / `fetch_buffer` /
`_warmed_up`) pointing at the previous connection. Because
`_produce` only calls `_try_connect` when `_state.inlet is None`, a
settings change that targeted a different stream never took effect —
the inlet kept pulling the original stream (and, when the new
settings reported an irregular rate, `_pull` could raise on the stale
`msg_template`).

Reset now tears down the existing connection and its derived state so
the next `_produce` re-resolves against the updated settings. Add a
regression test that connects to an 8-channel stream, pushes settings
targeting a 4-channel stream, and asserts the inlet reconnects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cboulay
cboulay merged commit 6e4e760 into dev Jul 8, 2026
2 checks passed
@cboulay
cboulay deleted the fix/inlet-reset-reconnect branch July 8, 2026 22:02
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.

1 participant