From 00b1af8f997b2ee88fffe408b820adff6fa6d565 Mon Sep 17 00:00:00 2001 From: Ilya Khrustalev Date: Sun, 17 Nov 2024 19:15:05 +0100 Subject: [PATCH] Fix database connections leakage (#980) --- src/khoj/database/adapters/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index 8538e217..fbfd5423 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -27,6 +27,7 @@ from django.contrib.sessions.backends.db import SessionStore from django.db.models import Prefetch, Q from django.db.models.manager import BaseManager from django.db.utils import IntegrityError +from django_apscheduler import util from django_apscheduler.models import DjangoJob, DjangoJobExecution from fastapi import HTTPException from pgvector.django import CosineDistance @@ -606,6 +607,7 @@ class ProcessLockAdapters: logger.debug(f"Skip removing {operation} process lock as it was not set") +@util.close_old_connections def run_with_process_lock(*args, **kwargs): """Wrapper function used for scheduling jobs. Required as APScheduler can't discover the `ProcessLockAdapter.run_with_lock' method on its own.