Django Channels 是否按预期作为 WSGI 应用程序工作?

Does Django Channels work as intended as a WSGI app?

我正在尝试实现 Django Channels,因为我需要让用户在另一个用户做某事时收到通知,而我对这部分完全感到困惑:

http://channels.readthedocs.io/en/stable/deploying.html

Deploying applications using channels requires a few more steps than a normal Django WSGI application, but you have a couple of options as to how to deploy it and how much of your traffic you wish to route through the channel layers.

Firstly, remember that it’s an entirely optional part of Django. If you leave a project with the default settings (no CHANNEL_LAYERS), it’ll just run and work like a normal WSGI app.

问题是我对正在使用的共享主机的权限非常有限,因此我无法使用 runworker 命令。

上面的引述说这部分是 "optional",没有它,它会像普通的 WSGI 应用程序一样工作。但是我可以将 Django Channels 与普通的 WSGI 应用程序一起使用吗?如果不是,那岂不是根本就不是可有可无的?

所以我的问题是:如果我跳过这部分,频道是否仍然有效,我是否能够使用此页面上显示的内容(路由、发送消息等):http://channels.readthedocs.io/en/stable/getting-started.html ?

通过阅读文档,我得到的是,首先您需要使用 运行 通道的后端,例如。 redis、Sharding 和 运行 "runworker",但由于它不适合您,请查看此 http://channels.readthedocs.io/en/stable/backends.html

"""The in-memory layer is only useful when running the protocol server and the worker server in a single process; the most common case of this is runserver, where a server thread, this channel layer, and worker thread all co-exist inside the same python process.""" 因此,通过避免第三方后端,您可以使用内存中的 asgi 层,只需 运行 'runserver' 即可设置通道层。只需在 link

中查找内存中的子主题

如果你保留 CHANNEL_LAYERS 空 django 将作为 wsgi 应用程序工作,但我们需要的是 asgi 应用程序,通道需要 asgi。