Opened 18 years ago

Closed 18 years ago

#3928 closed (duplicate)

FastCGI Unhandled Exception

Reported by: cpghost@… Owned by: Adrian Holovaty
Component: django-admin.py runserver Version: dev
Severity: Keywords: runfcgi fastcgi unhandled exception
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Running /usr/ports/www/py-django-devel (Django-20070214.tar.gz) on FreeBSD 6.2, I can't get FastCGI (with lighttpd) to run. The embedded (runserver) server works correctly, just runfcgi doesn't.

How to reproduce:


  1. Start lighttpd/fastcgi like this:
server.port                = 85
fastcgi.server             = ( "/" =>
                               ( "localhost" =>
                                 (
                                   "host" => "127.0.0.1",
                                   "port" => 10002,
                                   "bin-copy-environment" =>
                                   (
                                     "PATH", "SHELL", "USER"
                                   ),
                                   "broken-scriptfilename" => "enable",
                                 )
                               )
                            )
  1. django-admin.py startproject mysite
  1. cd mysite
  1. python manage.py runfcgi method=threaded host=127.0.0.1 port=10002 daemonize=True

Now access http://127.0.0.1:85/ (Unhandled Exception - instead of the Django greeting page),
and http://127.0.0.1:85/blah (404, as expected).

Adding a view and mapping it with urls.py also results in 404.

Everything works just fine with runserver, but not with runfcgi. Same problem with 0.95. Same problem with prefork instead of threaded.

Change History (5)

comment:1 by anonymous, 18 years ago

comment:2 by cpghost@…, 18 years ago

By applying the following patch to /usr/local/lib/python2.5/site-packages/django/core/servers/fastcgi.py:

--- fastcgi.py.orig     Wed Apr  4 21:51:34 2007
+++ fastcgi.py  Wed Apr  4 21:52:00 2007
@@ -118,7 +118,7 @@
     else:
         return fastcgi_help("ERROR: Implementation must be one of prefork or thread.")
 
-    wsgi_opts['debug'] = False # Turn off flup tracebacks
+    wsgi_opts['debug'] = True # Turn on flup tracebacks
 
     # Prep up and go
     from django.core.handlers.wsgi import WSGIHandler

and accessing http://127.0.0.1:85/, I get a long stack trace which ends like this:

 /usr/local/lib/python2.5/site-packages/django/core/handlers/base.py in get_response(self=<django.core.handlers.wsgi.WSGIHandler object at 0x831d7cc>, request=<WSGIRequest GET:<MultiValueDict: {}>, POST:<Mul...gi.url_scheme': 'http', 'wsgi.version': (1, 0)}>)
   57         # Apply request middleware
   58         for middleware_method in self._request_middleware:
   59             response = middleware_method(request)
   60             if response:
   61                 return response
response undefined, middleware_method = <bound method CommonMiddleware.process_request o...are.common.CommonMiddleware object at 0x84281ec>>, request = <WSGIRequest GET:<MultiValueDict: {}>, POST:<Mul...gi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
 /usr/local/lib/python2.5/site-packages/django/middleware/common.py in process_request(self=<django.middleware.common.CommonMiddleware object at 0x84281ec>, request=<WSGIRequest GET:<MultiValueDict: {}>, POST:<Mul...gi.url_scheme': 'http', 'wsgi.version': (1, 0)}>)
   39         # Append a slash if append_slash is set and the URL doesn't have a
   40         # trailing slash or a file extension.
   41         if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
   42             new_url[1] = new_url[1] + '/'
   43             if settings.DEBUG and request.method == 'POST':
global settings = <django.conf.LazySettings object at 0x82deeac>, settings.APPEND_SLASH = True, old_url = ['127.0.0.1:85', ''], ].split undefined

<type 'exceptions.IndexError'>: string index out of range

comment:3 by cpghost@…, 18 years ago

Another data point: lighttpd's error log:

2007-04-04 14:48:16: (mod_fastcgi.c.2502) FastCGI-stderr:  
2007-04-04 14:50:09: (mod_fastcgi.c.2502) FastCGI-stderr: Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/flup/server/fcgi_base.py", line 1112, in handler
    result = self.application(environ, start_response)
  File "/usr/local/lib/python2.5/site-packages/Django-0.95.1-py2.5.egg/django/core/handlers/wsgi.py", line 148, in __call__
    response = self.get_response(request.path, request)
  File "/usr/local/lib/python2.5/site-packages/Django-0.95.1-py2.5.egg/django/core/handlers/base.py", line 59, in get_response
    response = middleware_method(request)
  File "/usr/local/lib/python2.5/site-packages/Django-0.95.1-py2.5.egg/django/middleware/common.py", line 40, in process_request
    if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
IndexError: string index out of range

comment:4 by cpghost@…, 18 years ago

Ups, sorry, previous error log was with Django 0.95. Same with devel version:

2007-04-04 22:31:45: (mod_fastcgi.c.2502) FastCGI-stderr:  
2007-04-04 22:32:10: (mod_fastcgi.c.2502) FastCGI-stderr: Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/flup/server/fcgi_base.py", line 1112, in handler
    result = self.application(environ, start_response)
  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py", line 59, in get_response
    response = middleware_method(request)
  File "/usr/local/lib/python2.5/site-packages/django/middleware/common.py", line 41, in process_request
    if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
IndexError: string index out of range

comment:5 by James Bennett, 18 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #3414.

Note: See TracTickets for help on using tickets.
Back to Top