mirror of
https://github.com/apache/superset.git
synced 2026-05-06 08:24:26 +00:00
Small fixes
This commit is contained in:
@@ -273,7 +273,7 @@ SQLALCHEMY_CUSTOM_PASSWORD_STORE = None
|
||||
# "SINGLETON" reuses engines with connection pooling
|
||||
ENGINE_MANAGER_MODE = EngineModes.NEW
|
||||
|
||||
# Cleanup interval for abandoned locks in seconds (default: 5 minutes)
|
||||
# Cleanup interval for abandoned locks (default: 5 minutes)
|
||||
ENGINE_MANAGER_CLEANUP_INTERVAL = timedelta(minutes=5)
|
||||
|
||||
# Automatically start cleanup thread for SINGLETON mode (default: True)
|
||||
|
||||
@@ -334,10 +334,12 @@ class EngineManager:
|
||||
"null": pool.NullPool,
|
||||
"static": pool.StaticPool,
|
||||
}
|
||||
kwargs["poolclass"] = pools.get(extra["poolclass"], pool.QueuePool)
|
||||
pool_name = kwargs["poolclass"]
|
||||
if isinstance(pool_name, str):
|
||||
kwargs["poolclass"] = pools.get(pool_name, pool.QueuePool)
|
||||
|
||||
# update URI for specific catalog/schema
|
||||
connect_args = dict(extra.get("connect_args", {}))
|
||||
connect_args = kwargs.setdefault("connect_args", {})
|
||||
uri, connect_args = database.db_engine_spec.adjust_engine_params(
|
||||
uri,
|
||||
connect_args,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import atexit
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
@@ -50,6 +51,10 @@ class EngineManagerExtension:
|
||||
ssh_timeout = timedelta(seconds=app.config["SSH_TUNNEL_PACKET_TIMEOUT_SEC"])
|
||||
auto_start_cleanup = app.config["ENGINE_MANAGER_AUTO_START_CLEANUP"]
|
||||
|
||||
# Stop any existing manager's cleanup thread before creating a new one
|
||||
if self.engine_manager:
|
||||
self.engine_manager.stop_cleanup_thread()
|
||||
|
||||
# Create the engine manager
|
||||
self.engine_manager = EngineManager(
|
||||
engine_context_manager,
|
||||
@@ -67,15 +72,13 @@ class EngineManagerExtension:
|
||||
logger.info("Started EngineManager cleanup thread")
|
||||
|
||||
# Register shutdown handler
|
||||
def shutdown_engine_manager() -> None:
|
||||
def shutdown_engine_manager(exc: BaseException | None = None) -> None:
|
||||
if self.engine_manager:
|
||||
self.engine_manager.stop_cleanup_thread()
|
||||
|
||||
app.teardown_appcontext_funcs.append(lambda exc: None)
|
||||
app.teardown_appcontext(shutdown_engine_manager)
|
||||
|
||||
# Register with atexit for clean shutdown
|
||||
import atexit
|
||||
|
||||
atexit.register(shutdown_engine_manager)
|
||||
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user