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:
@@ -304,6 +304,14 @@ class Host:
|
||||
self.managers: list = [] # usernames with manager 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):
|
||||
d = {}
|
||||
d["raw_name"] = self.name
|
||||
|
||||
Reference in New Issue
Block a user