refactor: bind hot_reload event via EventDispatcher, add on_hot_reload to UAPIData
This commit is contained in:
parent
4360f34576
commit
e735070007
BIN
uapi/__pycache__/apidata.cpython-310.pyc
Normal file
BIN
uapi/__pycache__/apidata.cpython-310.pyc
Normal file
Binary file not shown.
BIN
uapi/__pycache__/init.cpython-310.pyc
Normal file
BIN
uapi/__pycache__/init.cpython-310.pyc
Normal file
Binary file not shown.
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user