Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket not accessible by Daphne server on Windows (due to Twisted, not Circus) #1058

Closed
jxrossel opened this issue Mar 7, 2018 · 8 comments

Comments

@jxrossel
Copy link

jxrossel commented Mar 7, 2018

Hi,

I'm trying to run Daphne (Django channels asgi server: https://github.com/django/daphne) with the following config file:

[circus]
check_delay = 5

[socket:web]
host = 0.0.0.0
port = 80

[watcher:daphne]
cmd = daphne
args = --fd $(circus.sockets.web) MYAPP.asgi:application 
use_sockets = True
numprocesses = 1

With the socket defined above, Daphne returns an error message:

'NoneType' object has no attribute 'fcntl'

which looks to me as if the socket object is "None". I've got the same message if I just run at the command line:

daphne --fd 5 MYAPP.asgi:application 

where the file descriptor has no meaning (i.e. not associated with anything).

Remarks:

  • Setting the host and port directly in the watcher args solves the issue, but then I can have only 1 process
  • With the socket, Daphne receives a file descriptor number, but it's like if the number isn't associated with anything
  • I'm on Windows 7 (that's maybe the issue here...)

Any help welcome here!

@k4nar
Copy link
Contributor

k4nar commented Mar 7, 2018

I don't see anything wrong with your config, so maybe it's linked to Windows yes. Do you have any way to try it with Linux (a Docker container should be fine)?

@jxrossel
Copy link
Author

jxrossel commented Mar 8, 2018

Thanks for the answer! I can't test on linux at work (Windows only, no admin rights...!). I've tried to see if I could test circus with sockets in a simpler case (with another server), but I can't find another server accepting --fd and working on Windows... I'll try to see if I can test this on linux at home.

@jxrossel
Copy link
Author

jxrossel commented Jul 6, 2018

I finally managed to test it on Linux. It does work there (with same python distribution (3.6) and same version of everything else). NB: last circus release (0.15) didn't help.

@k4nar
Copy link
Contributor

k4nar commented Jul 6, 2018

Yes sorry, the Windows support is not very active :/ . I managed to have a running version a few years back, but not to test it in CI. Since then there was some feedback & fixes, but not enough to guaranty that everything works as expected.

@jxrossel
Copy link
Author

jxrossel commented Jul 6, 2018

Thanks for the answer. Any hope of action towards that goal?

@k4nar
Copy link
Contributor

k4nar commented Jul 6, 2018

Not by me, but it's an Open Source project :) .

@jxrossel
Copy link
Author

@diorcety has submitted a pull request for a better Windows support (#1065). I've checked it out against this issue with no success. Just to let both of you know.

@jxrossel jxrossel changed the title socket not accessible by watcher (on Windows?) socket not accessible by watcher on Windows Jul 27, 2018
@jxrossel
Copy link
Author

jxrossel commented Aug 10, 2018

I've digged a bit more and found out that the problem lies with Twisted, on which the Daphne server is based. Twisted doesn't handle properly the opening of the socket from the inherited file descriptor on Windows. I could actually make it work by hacking Twisted a bit, even with the last stable release of Circus (i.e. without pull request #1065). Bug reported to Twisted team: https://twistedmatrix.com/trac/ticket/9508

@jxrossel jxrossel changed the title socket not accessible by watcher on Windows socket not accessible by Daphne server on Windows (due to Twisted, not Circus) Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants