Discussion:
Channels: development issue with multiple daphne workers
Zhiyu (Drew) Li
2018-11-26 23:09:27 UTC
Permalink
Hi there,

I am trying to migrate a tornado project to django channel2. I have moved
all essential parts and wired them up in channel. It runs OK in development
mode, but in production it seems the multi-daphne worker configuration is
causing strange errors.
AttributeError: '_UnixSelectorEventLoop' object has no attribute
'remove_timeout'

I followed instructions on the official doc (
https://channels.readthedocs.io/en/latest/deploying.html) to set up
supervisor and nginx. But I am still lack of understanding how it works.
Cloud you please explain more on the following settings?


*# TCP socket used by Nginx backend upstream*
*socket=tcp://localhost:8000*

*# Each process needs to have a separate socket file, so we use process_num*
*# Make sure to update "mysite.asgi" to match your project name*
*command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0
--access-log - --proxy-headers mysite.asgi:application*

*# Number of processes to startup, roughly the number of CPUs you have*
*numprocs=4*

*Questions:*
What is "--fd 0" here? Is "0" the file descriptor for socket
"tcp://localhost:8000" that Nginx is proxying to?
What is "-u /run/daphne/daphne%(process_num)d.sock" then? Why do we need to
set up separate socket for each daphne process? Are all the daphne
processes already talking to "fd 0"?

My website only works if I change either of the following
A) change to numprocs=1 ;
Or
B) remove "-u /run/daphne/daphne%(process_num)d.sock"

Thanks
Drew
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Godwin
2018-11-27 17:25:27 UTC
Permalink
I'm not sure why you're getting the _UnixSelectorEventLoop - that sounds
like a Twisted error you should search around for, and make sure you have
the right package versions.

--fd 0 should not be needed in that command line, since you're already
passing the UNIX socket, I don't remember why it's there.

I suggest you remove fd=0 and see if that then works with multiple
processes.

Andrew
Post by Zhiyu (Drew) Li
Hi there,
I am trying to migrate a tornado project to django channel2. I have moved
all essential parts and wired them up in channel. It runs OK in development
mode, but in production it seems the multi-daphne worker configuration is
causing strange errors.
AttributeError: '_UnixSelectorEventLoop' object has no attribute
'remove_timeout'
I followed instructions on the official doc (
https://channels.readthedocs.io/en/latest/deploying.html) to set up
supervisor and nginx. But I am still lack of understanding how it works.
Cloud you please explain more on the following settings?
*# TCP socket used by Nginx backend upstream*
*socket=tcp://localhost:8000*
*# Each process needs to have a separate socket file, so we use process_num*
*# Make sure to update "mysite.asgi" to match your project name*
*command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0
--access-log - --proxy-headers mysite.asgi:application*
*# Number of processes to startup, roughly the number of CPUs you have*
*numprocs=4*
*Questions:*
What is "--fd 0" here? Is "0" the file descriptor for socket
"tcp://localhost:8000" that Nginx is proxying to?
What is "-u /run/daphne/daphne%(process_num)d.sock" then? Why do we need
to set up separate socket for each daphne process? Are all the daphne
processes already talking to "fd 0"?
My website only works if I change either of the following
A) change to numprocs=1 ;
Or
B) remove "-u /run/daphne/daphne%(process_num)d.sock"
Thanks
Drew
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1uq88vgWuJDuyrc7o7tEdu1OT%2BU-i6yXZ2JuCEUD2%3DXeiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Zhiyu/Drew Li
2018-11-27 20:32:01 UTC
Permalink
Thanks Andrew,

I tried removing "--fd 0" but it didnt work. I got 504 time out error no
matter numprocs=1 or 4.
Do you know are there any open-source projects that use channel2? I just
want to take a look at their repos as my examples.

Thanks
Drew
Post by Andrew Godwin
I'm not sure why you're getting the _UnixSelectorEventLoop - that sounds
like a Twisted error you should search around for, and make sure you have
the right package versions.
--fd 0 should not be needed in that command line, since you're already
passing the UNIX socket, I don't remember why it's there.
I suggest you remove fd=0 and see if that then works with multiple
processes.
Andrew
Post by Zhiyu (Drew) Li
Hi there,
I am trying to migrate a tornado project to django channel2. I have moved
all essential parts and wired them up in channel. It runs OK in development
mode, but in production it seems the multi-daphne worker configuration is
causing strange errors.
AttributeError: '_UnixSelectorEventLoop' object has no attribute
'remove_timeout'
I followed instructions on the official doc (
https://channels.readthedocs.io/en/latest/deploying.html) to set up
supervisor and nginx. But I am still lack of understanding how it works.
Cloud you please explain more on the following settings?
*# TCP socket used by Nginx backend upstream*
*socket=tcp://localhost:8000*
*# Each process needs to have a separate socket file, so we use process_num*
*# Make sure to update "mysite.asgi" to match your project name*
*command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0
--access-log - --proxy-headers mysite.asgi:application*
*# Number of processes to startup, roughly the number of CPUs you have*
*numprocs=4*
*Questions:*
What is "--fd 0" here? Is "0" the file descriptor for socket
"tcp://localhost:8000" that Nginx is proxying to?
What is "-u /run/daphne/daphne%(process_num)d.sock" then? Why do we need
to set up separate socket for each daphne process? Are all the daphne
processes already talking to "fd 0"?
My website only works if I change either of the following
A) change to numprocs=1 ;
Or
B) remove "-u /run/daphne/daphne%(process_num)d.sock"
Thanks
Drew
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9657cf08-ced0-49d2-ab83-8338ebe1095a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...