refactor: bind hot_reload event via EventDispatcher, add on_hot_reload to PricingProgram

This commit is contained in:
yumoqing 2026-06-01 18:10:30 +08:00
parent 71329af722
commit 7b9d3d2ba0
5 changed files with 9 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -35,6 +35,9 @@ def load_pricing():
env.load_pricing_data = PricingProgram.load_pricing_data
env.get_pricing_program = PricingProgram.get_pricing_program
env.test_pricing = test_pricing
# Bind hot_reload event — staticmethod, ref safe (stored on class)
if hasattr(env, 'event_dispatcher'):
env.event_dispatcher.bind('hot_reload', PricingProgram.on_hot_reload)
dbpools = DBPools()
dbname = env.get_module_dbname('pricing')
if dbname:

View File

@ -186,6 +186,11 @@ def data_mapping(ns, name, v):
class PricingProgram:
pricing_data = {}
@staticmethod
def on_hot_reload(data=None):
"""Event handler for hot_reload event. Clears pricing cache."""
PricingProgram.pricing_data.clear()
@staticmethod
async def get_pricing_program(ppid):
env = ServerEnv()

View File

@ -1,7 +1,7 @@
{
"widgettype": "VBox",
"options": {
"cheight": 40,
"css": "filler", "height": "100%",
"width": "100%"
},
"subwidgets": [