Skip to content

Commit 6e1aa1c

Browse files
committed
Avoid resource leaks
1 parent b1f4700 commit 6e1aa1c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/runners/quota_scheduler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
9595
for limiter in config.limiters:
9696
try:
9797
if not connected(connection):
98+
# the old connection might be closed to avoid resource leaks
99+
try:
100+
connection.close()
101+
except Exception: # pylint: disable=broad-exception-caught
102+
pass # Connection already dead
98103
connection = connect(config)
99104
if connection is None:
100105
logger.warning("Can not connect to database, skipping")

0 commit comments

Comments
 (0)