Move set_on_changed registrations from on_process() to __init__()

Callbacks were registered inside the async on_process() coroutine,
meaning they weren't active until the event loop started ticking.
Moving them to __init__ ensures they're wired up at construction time.
Also removes remaining debug prints from the affected task files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tqxrk8uj4M3w3d3eXm3xK8
This commit is contained in:
2026-06-25 20:39:06 +02:00
co-authored by Claude Sonnet 4.6
parent 3ec0a248bb
commit 47fb09aa06
5 changed files with 18 additions and 30 deletions
+2 -4
View File
@@ -12,6 +12,8 @@ class PotTask(ATask):
self.msg_handler = msg_handler
msg_handler.set_recv_handler(self.recv)
self.plant = pot
pot.set_on_changed('power_actual', ChangedInteger(self.on_changed_power).set)
pot.set_on_changed('temp', ChangedFloat(self.on_changed_temp, prec=1).set)
def on_changed_power(self, value):
asyncio.create_task(self.send({'Power': value}))
@@ -33,10 +35,6 @@ class PotTask(ATask):
await self.msg_handler.send(data)
async def on_process(self):
print("{}: Started with interval {} s".format(self.msg_handler.get_key(), self.interval))
self.plant.set_on_changed('power_actual', ChangedInteger(self.on_changed_power).set)
self.plant.set_on_changed('temp', ChangedFloat(self.on_changed_temp, prec=1).set)
while True:
# Stays inert until a Sud actually supplies plant params (see
# tasks/sud.py's SudTask.apply_plant_params()) - process()