File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def initialise_database(db_uri: str) -> None:
16
16
"""Initialize the SQLAlchemy engine and session for genotype api."""
17
17
global SESSION , ENGINE
18
18
19
- ENGINE = create_engine (db_uri , pool_pre_ping = True , pool_recycle = 3600 )
19
+ ENGINE = create_engine (db_uri , pool_pre_ping = True )
20
20
session_factory = sessionmaker (ENGINE )
21
21
SESSION = scoped_session (session_factory )
22
22
@@ -61,6 +61,10 @@ def get_tables() -> list[str]:
61
61
return inspector .get_table_names ()
62
62
63
63
64
- def close_session ():
64
+ def close_session () -> None :
65
65
"""Close the global database session of the genotype api."""
66
- SESSION .remove ()
66
+ if SESSION :
67
+ session = SESSION ()
68
+ if session .is_active :
69
+ session .rollback ()
70
+ SESSION .remove ()
You can’t perform that action at this time.
0 commit comments