0👍
-
I doesn’t seem that the
lifespan
feature should be blocking any Django apps that are not using that feature. -
If you use sync code in your views, then switching to ASGI doesn’t magically make your view asynchronously. You need async wrappers around it. Check out Django docs about the adapters
sync_to_async()
andasync_to_sync()
. -
I have never seen the usage of
django.setup()
. I don’t understand your question fully. This is how anasgi.py
file should look like:
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
application = get_asgi_application()
Still, personally, after setting this all up, my views are still synchronously. I have opened this question about it: Uvicorn async workers are still working synchronously
-1👍
exec envdir .envdir gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--timeout 300 \
--workers $NUM_WORKERS \
--bind=unix:$SOCKFILE \
--preload \
-k uvicorn.workers.UvicornWorker
- [Django]-{{ STATIC_URL }} with pyjade in django
- [Django]-Django admin – prevent objects being saved, and don't show the user confirmation message
- [Django]-How do I reset PYTHONPATH to "default" value in virtualenv?
- [Django]-How to set PYTHONPATH on web server
Source:stackexchange.com