Django

Code

Ticket #8742 (closed: invalid)

Opened 2 years ago

Last modified 1 year ago

Windows support of FastCGI feature

Reported by: anonymous Assigned to: nobody
Milestone: Component: Uncategorized
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

(follow-up: ↓ 2 ) 09/01/08 05:23:56 changed by Daniel Pope <dan@mauveinternet.co.uk>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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 ) 09/02/08 02:18:26 changed by anonymous

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

09/02/08 02:28:14 changed by anonymous

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

09/02/08 03:32:21 changed by Daniel Pope <dan@mauveinternet.co.uk>

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.

11/27/08 04:46:31 changed 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="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.

02/25/09 15:25:55 changed by jacob

  • status changed from new to closed.
  • resolution set to invalid.

Add/Change #8742 (Windows support of FastCGI feature)




Change Properties
Action