diff --git a/uapi/__pycache__/apidata.cpython-310.pyc b/uapi/__pycache__/apidata.cpython-310.pyc new file mode 100644 index 0000000..417b1eb Binary files /dev/null and b/uapi/__pycache__/apidata.cpython-310.pyc differ diff --git a/uapi/__pycache__/init.cpython-310.pyc b/uapi/__pycache__/init.cpython-310.pyc new file mode 100644 index 0000000..131f67d Binary files /dev/null and b/uapi/__pycache__/init.cpython-310.pyc differ diff --git a/uapi/apidata.py b/uapi/apidata.py index 6bfa8fe..5923464 100644 --- a/uapi/apidata.py +++ b/uapi/apidata.py @@ -64,7 +64,13 @@ class UAPIData: self.apidata = {} self.apikeys = {} self.org_users = {} - + + def on_hot_reload(self, data=None): + """Event handler for hot_reload event. Clears all caches.""" + self.apidata.clear() + self.apikeys.clear() + self.org_users.clear() + async def get_userapikey(self, appid, callerid): users = await self.get_apiusers(appid) for u in users: diff --git a/uapi/init.py b/uapi/init.py index 04978ff..8e49e78 100644 --- a/uapi/init.py +++ b/uapi/init.py @@ -32,6 +32,9 @@ def load_uapi(): g.get_my_uptasks = get_my_uptasks g.uptask_feedback = uptask_feedback g.uptask_started = uptask_started + # Bind hot_reload event — instance method, WeakMethod safe (stored on g) + if hasattr(g, 'event_dispatcher'): + g.event_dispatcher.bind('hot_reload', g.uapi_data.on_hot_reload) # USAGE in dspy