diff --git a/backend/app/crypto_agent/crypto_agent.py b/backend/app/crypto_agent/crypto_agent.py index 150a7f8..904ca2e 100644 --- a/backend/app/crypto_agent/crypto_agent.py +++ b/backend/app/crypto_agent/crypto_agent.py @@ -667,7 +667,6 @@ _crypto_agent: Optional['CryptoAgent'] = None def get_crypto_agent() -> 'CryptoAgent': """获取加密货币智能体单例""" - global _crypto_agent - if _crypto_agent is None: - _crypto_agent = CryptoAgent() - return _crypto_agent + # 直接使用类单例,不使用全局变量(避免 reload 时重置) + return CryptoAgent() + diff --git a/backend/app/services/price_monitor_service.py b/backend/app/services/price_monitor_service.py index fc71918..0cca589 100644 --- a/backend/app/services/price_monitor_service.py +++ b/backend/app/services/price_monitor_service.py @@ -217,7 +217,6 @@ _price_monitor_service: Optional[PriceMonitorService] = None def get_price_monitor_service() -> PriceMonitorService: """获取价格监控服务单例""" - global _price_monitor_service - if _price_monitor_service is None: - _price_monitor_service = PriceMonitorService() - return _price_monitor_service + # 直接使用类单例,不使用全局变量(避免 reload 时重置) + return PriceMonitorService() +