-
-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
Description
写异步的 Django 代码 !!!
pip install -U channels
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
...
'channels',
)
from channels.routing import ProtocolTypeRouter
application = ProtocolTypeRouter({
# Empty for now (http->django views is added by default)
})
# asgi:
ASGI_APPLICATION = "myproject.routing.application"
- channel 2: 新特性: https://channels.readthedocs.io/en/latest/one-to-two.html#full-async
- full async (全异步)
- Full Async
Channels 2 is also built on a fundamental async foundation, and all servers are actually running an asynchronous event loop and only jumping to synchronous code when you interact with the Django view system or ORM. That means that you, too, can write fully asychronous code if you wish.