【问题标题】:Django channels run three workers, is it normal?django频道跑三个worker,正常吗?
【发布时间】:2017-05-10 01:46:11
【问题描述】:

我有一个非常简单的 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

而且三名工人好像出了什么问题,还是正常的? 但其他一切正常。

非常感谢您的建议

【问题讨论】:

  • 它没有记录,但我认为没关系

标签: django channels django-channels


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2021-12-22
    • 1970-01-01
    • 2012-01-15
    • 2021-07-08
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多