mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-16 07:19:13 +08:00
Remove future, autocommit args from session and engine creation
This commit is contained in:
@@ -123,7 +123,6 @@ class ItemGrabber:
|
||||
self.self_handler_tags = self_handler_tags
|
||||
self.max_grab = max_grab
|
||||
self.handler_tags = handler_tags
|
||||
self._grab_conn_opts = {"autocommit": False}
|
||||
self._grab_query = None
|
||||
self._supports_returning = self.app.application_stack.supports_returning()
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ def check_database_connection(session):
|
||||
class ModelMapping(Bunch):
|
||||
def __init__(self, model_modules, engine):
|
||||
self.engine = engine
|
||||
self._SessionLocal = sessionmaker(autoflush=False, autocommit=False, future=True)
|
||||
self._SessionLocal = sessionmaker(autoflush=False)
|
||||
versioned_session(self._SessionLocal)
|
||||
context = scoped_session(self._SessionLocal, scopefunc=self.request_scopefunc)
|
||||
# For backward compatibility with "context.current"
|
||||
|
||||
@@ -45,7 +45,7 @@ def create_database(db_url, database=None, encoding="utf8", template=None):
|
||||
|
||||
@contextmanager
|
||||
def sqlalchemy_engine(url):
|
||||
engine = create_engine(url, future=True)
|
||||
engine = create_engine(url)
|
||||
try:
|
||||
yield engine
|
||||
finally:
|
||||
|
||||
@@ -124,10 +124,10 @@ def verify_databases_via_script(
|
||||
) -> None:
|
||||
# This function serves a use case when an engine has not been created yet
|
||||
# (e.g. when called from a script).
|
||||
gxy_engine = create_engine(gxy_config.url, future=True)
|
||||
gxy_engine = create_engine(gxy_config.url)
|
||||
tsi_engine = None
|
||||
if tsi_config.url and tsi_config.url != gxy_config.url:
|
||||
tsi_engine = create_engine(tsi_config.url, future=True)
|
||||
tsi_engine = create_engine(tsi_config.url)
|
||||
|
||||
verify_databases(
|
||||
gxy_engine,
|
||||
|
||||
@@ -116,7 +116,7 @@ def _configure_and_run_migrations_offline(url: str) -> None:
|
||||
|
||||
|
||||
def _configure_and_run_migrations_online(url) -> None:
|
||||
engine = create_engine(url, future=True)
|
||||
engine = create_engine(url)
|
||||
with engine.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
|
||||
@@ -59,7 +59,7 @@ def verify_database_is_initialized(db_url: str) -> None:
|
||||
if not database_exists(db_url):
|
||||
raise DatabaseDoesNotExistError(db_url)
|
||||
|
||||
engine = create_engine(db_url, future=True)
|
||||
engine = create_engine(db_url)
|
||||
try:
|
||||
db_state = DatabaseStateCache(engine=engine)
|
||||
if db_state.is_database_empty() or db_state.contains_only_kombu_tables():
|
||||
@@ -161,7 +161,7 @@ class LegacyManageDb:
|
||||
"""
|
||||
db_url = gxy_db_url or self.gxy_db_url
|
||||
try:
|
||||
engine = create_engine(db_url, future=True)
|
||||
engine = create_engine(db_url)
|
||||
version = self._get_gxy_alembic_db_version(engine)
|
||||
if not version:
|
||||
version = self._get_gxy_sam_db_version(engine)
|
||||
@@ -197,7 +197,7 @@ class LegacyManageDb:
|
||||
|
||||
def _upgrade(self, db_url, model):
|
||||
try:
|
||||
engine = create_engine(db_url, future=True)
|
||||
engine = create_engine(db_url)
|
||||
am = get_alembic_manager(engine)
|
||||
am.upgrade(model)
|
||||
finally:
|
||||
|
||||
@@ -106,9 +106,9 @@ def build_engine(
|
||||
set_sqlite_connect_args(engine_options, url)
|
||||
|
||||
if url.startswith("sqlite://") and url not in ("sqlite:///:memory:", "sqlite://"):
|
||||
engine = create_engine(url, **engine_options, poolclass=NullPool, future=True)
|
||||
engine = create_engine(url, **engine_options, poolclass=NullPool)
|
||||
else:
|
||||
engine = create_engine(url, **engine_options, future=True)
|
||||
engine = create_engine(url, **engine_options)
|
||||
|
||||
# Prevent sharing connection across fork: https://docs.sqlalchemy.org/en/14/core/pooling.html#using-connection-pools-with-multiprocessing-or-os-fork
|
||||
register_after_fork(engine, lambda e: e.dispose())
|
||||
|
||||
@@ -76,7 +76,7 @@ def get_db_heads(config: Config) -> Tuple[str, ...]:
|
||||
"""Return revision ids (version heads) stored in the database."""
|
||||
dburl = config.get_main_option("sqlalchemy.url")
|
||||
assert dburl
|
||||
engine = create_engine(dburl, future=True)
|
||||
engine = create_engine(dburl)
|
||||
with engine.connect() as conn:
|
||||
context = MigrationContext.configure(conn)
|
||||
heads = context.get_current_heads()
|
||||
|
||||
@@ -67,7 +67,7 @@ def drop_existing_database(url: DbUrl) -> Iterator[None]:
|
||||
@contextmanager
|
||||
def disposing_engine(url: DbUrl) -> Iterator[Engine]:
|
||||
"""Context manager for engine that disposes of its connection pool on exit."""
|
||||
engine = create_engine(url, future=True)
|
||||
engine = create_engine(url)
|
||||
try:
|
||||
yield engine
|
||||
finally:
|
||||
@@ -233,7 +233,7 @@ def _drop_postgres_database(url: DbUrl) -> None:
|
||||
|
||||
|
||||
def _drop_database(connection_url, database_name):
|
||||
engine = create_engine(connection_url, isolation_level="AUTOCOMMIT", future=True)
|
||||
engine = create_engine(connection_url, isolation_level="AUTOCOMMIT")
|
||||
preparer = IdentifierPreparer(engine.dialect)
|
||||
database_name = preparer.quote(database_name)
|
||||
stmt = text(f"DROP DATABASE IF EXISTS {database_name}")
|
||||
|
||||
@@ -46,7 +46,7 @@ class RevisionNotFoundError(Exception):
|
||||
|
||||
def verify_database(url, engine_options=None) -> None:
|
||||
engine_options = engine_options or {}
|
||||
engine = create_engine(url, **engine_options, future=True)
|
||||
engine = create_engine(url, **engine_options)
|
||||
verifier = DatabaseStateVerifier(engine)
|
||||
verifier.run()
|
||||
engine.dispose()
|
||||
|
||||
@@ -62,7 +62,7 @@ def _configure_and_run_migrations_offline(url: str) -> None:
|
||||
|
||||
|
||||
def _configure_and_run_migrations_online(url) -> None:
|
||||
engine = create_engine(url, future=True)
|
||||
engine = create_engine(url)
|
||||
with engine.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
|
||||
@@ -49,7 +49,7 @@ def find_missing_indexes():
|
||||
# create EMPTY metadata, then load from database
|
||||
db_url = get_config(sys.argv)["db_url"]
|
||||
metadata = MetaData()
|
||||
engine = create_engine(db_url, future=True)
|
||||
engine = create_engine(db_url)
|
||||
metadata.reflect(bind=engine)
|
||||
indexes_in_db = load_indexes(metadata)
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ def create_database(config_file):
|
||||
exit(1)
|
||||
|
||||
# Initialize the database connection.
|
||||
engine = create_engine(database_connection, future=True)
|
||||
engine = create_engine(database_connection)
|
||||
MetaData(bind=engine)
|
||||
install_session = scoped_session(sessionmaker(bind=engine, autoflush=False, autocommit=True))
|
||||
install_session = scoped_session(sessionmaker(bind=engine, autoflush=False))
|
||||
model = mapping.init(database_connection)
|
||||
return install_session, model
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def sqlite_memory_url():
|
||||
@pytest.fixture(scope="module")
|
||||
def engine():
|
||||
db_uri = "sqlite:///:memory:"
|
||||
return create_engine(db_uri, future=True)
|
||||
return create_engine(db_uri)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user