Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
Django + Uvicorn

I'm trying to use Django 3.0 with Uvicorn and getting this on start:

INFO:     Started server process [96219]
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.

I could turn lifespan off with the --lifespan off flag, but is there a way to have it work with Django? A quick search for Django + lifespan seems to not return anything.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

No, lifespan protocol doesn't work with Django 3.0.

See this ticket: https://code.djangoproject.com/ticket/31508

over 4 years ago · Santiago Trujillo Report

0

Here's the initial setup I used with django 3.1 / 3.2

EDIT: some rough performance benchmarks: https://github.com/allen-munsch/benchmark-django-fastapi

old version

your_django/old_wsgi.py:

import os

from django.core.wsgi import get_wsgi_application
from dj_static import Cling

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_django.settings")

application = Cling(get_wsgi_application())

Previously run as:

newrelic-admin run-program gunicorn your_django.old_wsgi \
-k eventlet --log-file - --timeout 60

new version

your_django/asgi.py:

import os

from django.core.asgi import get_asgi_application
from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pm.settings")

application = ASGIStaticFilesHandler(
    get_asgi_application()
)

And to run

gunicorn your_django.asgi --log-level=debug -k uvicorn.workers.UvicornWorker \
--log-file - --timeout 60

# OR for local dev

uvicorn --reload your_django.asgi

related:

  • https://stackoverflow.com/a/67275668/2026508
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!