From 5d4e008ec83992fa8eecb820d1b380c85be1e1fc Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 2 Jun 2026 17:36:38 +0800 Subject: [PATCH] fix: guard hot_reload binding with None check hasattr only checks attribute existence, but event_dispatcher can exist as None when running standalone (backend_accounting.py). Use getattr with None check instead. --- pricing/init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pricing/init.py b/pricing/init.py index 7e8254d..5ac5ff3 100644 --- a/pricing/init.py +++ b/pricing/init.py @@ -33,8 +33,8 @@ 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'): + # Bind hot_reload event — only when running in ahserver (event_dispatcher available) + if getattr(env, 'event_dispatcher', None) is not None: env.event_dispatcher.bind('hot_reload', PricingProgram.on_hot_reload) dbpools = DBPools() dbname = env.get_module_dbname('pricing')