mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-13 09:30:54 +00:00
Upgrade SQLAlchemy version and dispose of db engine
This commit is contained in:
parent
6af1f2afaa
commit
010d7aa49f
@ -15,7 +15,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import sys
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
@ -25,7 +24,7 @@ from gns3server.controller import Controller
|
|||||||
from gns3server.compute import MODULES
|
from gns3server.compute import MODULES
|
||||||
from gns3server.compute.port_manager import PortManager
|
from gns3server.compute.port_manager import PortManager
|
||||||
from gns3server.utils.http_client import HTTPClient
|
from gns3server.utils.http_client import HTTPClient
|
||||||
from gns3server.db.tasks import connect_to_db, get_computes
|
from gns3server.db.tasks import connect_to_db, disconnect_from_db, get_computes
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -90,4 +89,6 @@ def create_shutdown_handler(app: FastAPI) -> Callable:
|
|||||||
if PortManager.instance().udp_ports:
|
if PortManager.instance().udp_ports:
|
||||||
log.warning(f"UDP ports are still used {PortManager.instance().udp_ports}")
|
log.warning(f"UDP ports are still used {PortManager.instance().udp_ports}")
|
||||||
|
|
||||||
|
await disconnect_from_db(app)
|
||||||
|
|
||||||
return shutdown_handler
|
return shutdown_handler
|
||||||
|
@ -51,6 +51,14 @@ async def connect_to_db(app: FastAPI) -> None:
|
|||||||
log.fatal(f"Error while connecting to database '{db_url}: {e}")
|
log.fatal(f"Error while connecting to database '{db_url}: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
async def disconnect_from_db(app: FastAPI) -> None:
|
||||||
|
|
||||||
|
# dispose of the connection pool used by the database engine
|
||||||
|
if getattr(app.state, "_db_engine"):
|
||||||
|
await app.state._db_engine.dispose()
|
||||||
|
log.info(f"Disconnected from database")
|
||||||
|
|
||||||
|
|
||||||
@event.listens_for(Engine, "connect")
|
@event.listens_for(Engine, "connect")
|
||||||
def set_sqlite_pragma(dbapi_connection, connection_record):
|
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ sentry-sdk==1.5.7
|
|||||||
psutil==5.9.0
|
psutil==5.9.0
|
||||||
distro==1.7.0
|
distro==1.7.0
|
||||||
py-cpuinfo==8.0.0
|
py-cpuinfo==8.0.0
|
||||||
sqlalchemy==1.4.32
|
sqlalchemy==1.4.35
|
||||||
aiosqlite===0.17.0
|
aiosqlite===0.17.0
|
||||||
passlib[bcrypt]==1.7.4
|
passlib[bcrypt]==1.7.4
|
||||||
python-jose==3.3.0
|
python-jose==3.3.0
|
||||||
|
Loading…
Reference in New Issue
Block a user