Compare commits

...

2 commits

Author SHA1 Message Date
a1ddb43ed0
Handle abnormal closure of websocket 2025-03-13 16:55:56 +00:00
49f84755f1
Configure alembic to use dotenv 2025-03-13 16:47:29 +00:00
2 changed files with 5 additions and 1 deletions

View file

@ -1,9 +1,12 @@
from logging.config import fileConfig
import os
from dotenv import load_dotenv
from sqlalchemy import create_engine
from alembic import context
load_dotenv()
# Import models for autogenerate support
from app.database import Base
from app.models import *

View file

@ -3,6 +3,7 @@ from typing import Any, Coroutine, Dict
from uuid import UUID
from websockets import ConnectionClosed
from starlette.websockets import WebSocketDisconnect
from app.ocpp_proto.chargepoint import ChargePoint
@ -12,7 +13,7 @@ async def start(id: UUID, cp: ChargePoint):
try:
__active_connections[id] = cp
await cp.start()
except ConnectionClosed:
except (ConnectionClosed, WebSocketDisconnect):
logging.info("Charging station '%s' (%s) disconnected", cp.id, id)
__active_connections.pop(id, None)