Skip to content

Commit c258a8d

Browse files
Fix handling of NoResultFound exception in decrement_qos_rule_running function
1 parent a8fa338 commit c258a8d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cads_broker/database.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,13 @@ def increment_qos_rule_running(rules: list, session: sa.orm.Session):
474474
def decrement_qos_rule_running(rules: list, session: sa.orm.Session):
475475
"""Increment the running counter of a QoS rule."""
476476
for rule in rules:
477-
qos_rule = get_qos_rule(str(rule.__hash__()), session)
478-
qos_rule.running = max(0, qos_rule.running - 1)
477+
try:
478+
qos_rule = get_qos_rule(str(rule.__hash__()), session)
479+
qos_rule.running = max(0, qos_rule.running - 1)
480+
except sqlalchemy.orm.exc.NoResultFound:
481+
# this happend when a request is finished after a broker restart.
482+
# the rule is not in the database anymore because it has been reset.
483+
continue
479484
session.commit()
480485

481486

0 commit comments

Comments
 (0)