aminghadersohi commented on code in PR #35163: URL: https://github.com/apache/superset/pull/35163#discussion_r2364348510
########## superset/mcp_service/flask_singleton.py: ########## @@ -0,0 +1,78 @@ +""" +Singleton pattern for Flask app creation in MCP service. + +This module ensures that only one Flask app instance is created and reused +throughout the MCP service lifecycle. This prevents issues with multiple +app instances and improves performance. +""" + +import logging +import threading +from typing import Optional + +from flask import Flask + +logger = logging.getLogger(__name__) + +# Singleton instance storage +_flask_app: Optional[Flask] = None +_flask_app_lock = threading.Lock() + + +def get_flask_app() -> Flask: Review Comment: ah yea i see it got too complex. let me simplify it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
