Django channels run three workers, is it normal?

1.6k views Asked by At

I have a very simple setup of django project with channels using documentation https://channels.readthedocs.io/en/stable/getting-started.html

In settings:

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

In rounting.py:

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

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

And when i run:

python manage.py runserver

it prints:

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

And three workers seems that something went wrong, or it is normal? But everything else works fine.

Big thx for advices

1

There are 1 answers

0
Piet van Leeuwen On BEST ANSWER

Locally when I run the ./manage.py runserver command I get 4 workers by default.

Possibly this line on the channels runserver command - https://github.com/django/channels/blob/a3f4e002eeebbf7c2412d9623e4e9809cfe32ba5/channels/management/commands/runserver.py#L80

To have a single worker running you can use the channels command ./manage.py runworker.