1

我有一个非常简单的 django 项目设置,使用文档 https://channels.readthedocs.io/en/stable/getting-started.html

在设置中:

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgiref.inmemory.ChannelLayer",
        "ROUTING": "core.routing.channel_routing",
    },
}

在 rounting.py 中:

from channels.routing import route
from apps.prices.consumers import get_prices

channel_routing = [
    route('get_prices', get_prices),
]

当我运行时:

python manage.py runserver

它打印:

2016-12-24 23:49:05,202 - INFO - worker - Listening on channels get_prices, http.request, websocket.connect, websocket.receive
2016-12-24 23:49:05,202 - INFO - worker - Listening on channels get_prices, http.request, websocket.connect, websocket.receive
2016-12-24 23:49:05,203 - INFO - worker - Listening on channels get_prices, http.request, websocket.connect, websocket.receive
2016-12-24 23:49:05,207 - INFO - server - Using busy-loop synchronous mode on channel layer

而三个工人似乎出了什么问题,还是正常的?但其他一切正常。

非常感谢您的建议

4

1 回答 1

1

在本地,当我运行./manage.py runserver命令时,默认情况下我会得到 4 个工作人员。

可能是频道 runserver 命令上的这一行 - https://github.com/django/channels/blob/a3f4e002eeebbf7c2412d9623e4e9809cfe32ba5/channels/management/commands/runserver.py#L80

要让单个工作人员运行,您可以使用通道命令./manage.py runworker

于 2017-10-09T22:56:03.537 回答