Opened 10 years ago

Closed 9 years ago

#8742 closed (invalid)

Windows support of FastCGI feature

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


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

Currently the FastCGI feature of Django ( 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. ( 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 ( but the patch is not yet applied on the Windows release, even on Python 2.6b2. Rewriting the FastCGI feature with 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 Changed 10 years ago by Daniel Pope <dan@…>

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 runfcgi method=threaded works?

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

comment:2 in reply to:  1 Changed 10 years ago by anonymous

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

comment:3 Changed 10 years ago by anonymous

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

comment:4 Changed 10 years ago by Daniel Pope <dan@…>

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 Changed 10 years ago by snaury

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="", 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<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 Changed 9 years ago by Jacob

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