Opened 16 years ago

Closed 16 years ago

#8742 closed (invalid)

Windows support of FastCGI feature

Reported by: anonymous Owned by: nobody
Component: Uncategorized Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django FastCGI cannot be used on Windows, and possibly other non-Unix environments.

Currently the FastCGI feature of Django (manage.py runfcgi) relies on the Python library 'flup', which relies on Unix-only socket functions (socket.socketpair(), socket.fromfd(), etc.) making it impossible to use the FastCGI feature of Django on non-Unix envs like Windows, and hence, making it impossible to serve Django with non-Apache (non-mod_python) httpds like lighttpd on non-Unix envs.

Possible solutions: The function socketpair() is unofficially implemented on Windows by a recipe. (http://code.activestate.com/recipes/525487/) Committing this patch to the flup project is not a hard work. However, the function fromfd() has nothing like that. There is a patch enabling its Windows use (http://bugs.python.org/issue1378) but the patch is not yet applied on the Windows release, even on Python 2.6b2. Rewriting the FastCGI feature with python-fastcgi (http://pypi.python.org/pypi/python-fastcgi) could be a more work than flup, but then the feature can support Windows.

Unix environments, especially GNU/Linux, is of course better than Windows to be used as a web server, but there are some situations where Windows and FastCGI have to be used. It would be good to have Django FastCGI available on Windows.

Change History (6)

comment:1 by Daniel Pope <dan@…>, 16 years ago

flup (and by extension Django) does not officially support FastCGI on Windows.

However, according to the FAQ, threaded servers are reported to work under Windows; could you determine whether manage.py runfcgi method=threaded works?

We could add a note in the documentation drawing attention to this fact.

in reply to:  1 comment:2 by anonymous, 16 years ago

No, it doesn't work, resulting an AttributeError: 'module' object has no attribute 'fromfd'.

comment:3 by anonymous, 16 years ago

i mean, it 'still' doesn't work, even with method=threaded.

comment:4 by Daniel Pope <dan@…>, 16 years ago

The other thing I can suggest is to try AJP or SCGI. A quick grep shows no instances of fromfd or socketpair in the AJP server code.

comment:5 by snaury, 16 years ago

I can confirm that flup works on Windows and Apache, just not the way most people expect (due to principal differences between files and sockets on Windows). To make it work, you need to start your server like this in your dispatch.fcgi:

from django.core.servers.fastcgi import runfastcgi
runfastcgi(protocol="fcgi", method="threaded", daemonize="false", host="127.0.0.1", port=port)

Then in your httpd.conf you will need to make apache aware of your server:

FastCgiExternalServer <path-to-your-wwwroot>/dispatch.fcgi -host 127.0.0.1:<port>

Of course with this setup apache won't start your fastcgi server for you (and frankly, with the way python (or flup, I'm not sure) handles signals on Windows you DON'T want apache to start python servers for you, as it won't be able to kill them afterwards), you'll need to do it yourself separately. I, for example, run my fastcgi server as a Windows service (using win32service), which is even better since with this setup apache and fastcgi servers can run as different users.

comment:6 by Jacob, 16 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top