A supervised loop that crashes reports its node down
A push session that failed before it listened left only a task_crashed event. The wrapper in _run_supervised now reports down with the exception, unless the loop already said why it is down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
@@ -14,6 +14,7 @@ from fluksio.flow.messages import DType, MessageSpec
|
||||
from fluksio.flow.nodes import Node
|
||||
from fluksio.flow.pipeline import Pipeline
|
||||
from fluksio.flow.plugins import load_plugins
|
||||
from fluksio.flow.supervision import Supervisor
|
||||
|
||||
|
||||
class Sensor(ConnectorNode):
|
||||
@@ -156,6 +157,35 @@ def test_an_undeclared_port_keeps_failing_until_the_node_declares_it():
|
||||
assert len([entry for entry in health if entry[0] == "down"]) > 1
|
||||
|
||||
|
||||
def test_a_push_session_that_fails_before_it_listens_reports_down():
|
||||
"""A crashed loop is node health, not only a crash event."""
|
||||
|
||||
class Push(Sensor):
|
||||
async def start(self, app: Any = None) -> None:
|
||||
self._run_supervised("push", self._session)
|
||||
|
||||
async def _session(self) -> None:
|
||||
raise ConnectionError("bridge unreachable")
|
||||
|
||||
health: list[tuple[str, str | None]] = []
|
||||
node = Push(provides=[MessageSpec(name="reading", dtype=DType.FLOAT)])
|
||||
node.assign_flow("demo", "push")
|
||||
node._on_health = lambda _node, status, detail: health.append((status, detail))
|
||||
|
||||
async def scenario() -> None:
|
||||
node.supervisor = Supervisor()
|
||||
await node.start()
|
||||
for _ in range(500):
|
||||
if health:
|
||||
break
|
||||
await asyncio.sleep(0.01)
|
||||
await node.supervisor.cancel_all()
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
assert health == [("down", "ConnectionError: bridge unreachable")]
|
||||
|
||||
|
||||
class Actuator(ConnectorNode):
|
||||
"""A connector that commands something instead of reading it."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user