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
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
.