From a9c383e62cc62ab5b5231aeb1370407e83de24a3 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 5 Jun 2024 09:25:08 +0530 Subject: [PATCH] Use an ASGI application, rather than WSGI - ASGI should be the preferred application, as our codebase runs a lot of async code --- src/khoj/app/asgi.py | 16 ++++++++++++++++ src/khoj/app/settings.py | 2 +- src/khoj/app/wsgi.py | 16 ---------------- src/khoj/configure.py | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/khoj/app/asgi.py delete mode 100644 src/khoj/app/wsgi.py diff --git a/src/khoj/app/asgi.py b/src/khoj/app/asgi.py new file mode 100644 index 00000000..d0709b5b --- /dev/null +++ b/src/khoj/app/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for app project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "khoj.app.settings") + +application = get_asgi_application() diff --git a/src/khoj/app/settings.py b/src/khoj/app/settings.py index a46e83f9..349e48ae 100644 --- a/src/khoj/app/settings.py +++ b/src/khoj/app/settings.py @@ -108,7 +108,7 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = "app.wsgi.application" +ASGI_APPLICATION = "app.asgi.application" # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases diff --git a/src/khoj/app/wsgi.py b/src/khoj/app/wsgi.py deleted file mode 100644 index 03956936..00000000 --- a/src/khoj/app/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for app project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "khoj.app.settings") - -application = get_wsgi_application() diff --git a/src/khoj/configure.py b/src/khoj/configure.py index 548f2fe9..dc33586b 100644 --- a/src/khoj/configure.py +++ b/src/khoj/configure.py @@ -328,7 +328,7 @@ def update_content_index_regularly(): ) -@schedule.repeat(schedule.every(1).to(2).hours) +@schedule.repeat(schedule.every(30).to(59).minutes) def close_all_db_connections(): from django import db