Skip to content

Commit bdfb0c7

Browse files
committed
Catch KeyError if there is no monitoring switch to remove
1 parent 8bd267a commit bdfb0c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/murfey/server/api/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,10 @@ async def process_gain(
16431643
@router.delete("/sessions/{session_id}")
16441644
def remove_session_by_id(session_id: MurfeySessionID, db=murfey_db):
16451645
session = db.exec(select(Session).where(Session.id == session_id)).one()
1646-
prom.monitoring_switch.remove(session.visit)
1646+
try:
1647+
prom.monitoring_switch.remove(session.visit)
1648+
except KeyError:
1649+
pass
16471650
rsync_instances = db.exec(
16481651
select(RsyncInstance).where(RsyncInstance.session_id == session_id)
16491652
).all()

0 commit comments

Comments
 (0)