Django 4.0 ASGI lifespan error
Hi guys,
I'm completely new to getting Python up and running with Unit and if this is actually just a Django error, please let me know but I did simply follow the docs and am seeing the below error on a completely fresh Python 3.10 + Django 4.0 app:
2021/12/09 18:17:56 [info] 233#233 "python" application started
2021/12/09 18:17:56 [info] 0#233 [unit] ASGI Lifespan processing exception
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/asgi.py", line 143, in __call__
raise ValueError(
ValueError: Django can only handle ASGI/HTTP connections, not lifespan.
2021/12/09 18:17:56 [info] 233#234 [unit] ASGI Lifespan processing exception
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/asgi.py", line 143, in __call__
raise ValueError(
ValueError: Django can only handle ASGI/HTTP connections, not lifespan.
Is this a Unit problem, or a Django problem? Django 4.0 was just released so maybe it's just a compatibility problem with 4.0?
Starting Unit with the wsgi handler works fine, no errors. Config is simple:
"python": {
"type": "python",
"path": "/path/to/project/django_example",
"module": "django_example.asgi",
"callable": "application"
}
Thanks!
Hello. This is not an error. Just ignore it. ASGI spec allows to throw an exception during lifetime processing. Maybe we should log such message on debug level..
Btw, does your ASGI application works as expected (except the lifespan messages)?
Ok, great, I didn't realize the error was nothing to worry about. If it's nothing to be concerned about, I would agree, perhaps that should only log on debug.
Btw, does your ASGI application works as expected (except the lifespan messages)?
Yes, it seems to. Nothing to worry about then.
Thanks for the quick reply.