fix: strip plugin timers when pickling Host to prevent save failure

Host.plugin_timers holds asyncio TimerHandle objects (and their lambda
callbacks) which are not picklable, causing the 5-minute state save to
fail with "Can't pickle local object reset_plugin_timer.<locals>.<lambda>".
Add Host.__getstate__ to reset plugin_timers to {} before pickling,
mirroring Connection.__getstate__; timers are recreated on the next PLG.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 11:37:35 -04:00
co-authored by Claude Opus 4.8
parent 6282077fe0
commit 356c77b0b8
+8
View File
@@ -304,6 +304,14 @@ class Host:
self.managers: list = [] # usernames with manager role self.managers: list = [] # usernames with manager role
self.monitors: list = [] # usernames with monitor role self.monitors: list = [] # usernames with monitor role
def __getstate__(self):
"""Prepare Host for pickling by excluding non-serializable timer objects."""
state = self.__dict__.copy()
# asyncio TimerHandles (and their lambda callbacks) can't be pickled.
# They're recreated when the next PLG arrives after unpickling.
state['plugin_timers'] = {}
return state
def statedict(self): def statedict(self):
d = {} d = {}
d["raw_name"] = self.name d["raw_name"] = self.name