Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hit something similar - we've got Django behind NGINX, and we allow Django to handle 500s - this works 99.9% of the time, but when we're doing upgrades, sometimes these "Unhandled Exceptions" slip through.</p> <p>Django doesn't override flup's hooks for handling errors, so we'll need to do that ourselves, and let Django handle these errors.</p> <p>First override <a href="http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L1210" rel="noreferrer"><code>flup.server.BaseFCGIServer.error</code></a> to errors through Django. Then we'll tell Django to use our modified <code>BaseFCGIServer</code> to see those errors.</p> <p>Since Python is awesome, we'll cheat and just monkeypatch the whole thing in one place, <a href="http://code.djangoproject.com/browser/django/trunk/django/core/servers/fastcgi.py" rel="noreferrer"><code>django.core.servers.fastcgi.py</code></a>. Here we go:</p> <pre><code># django.core.servers.fastcgi.py def runfastcgi(argset=[], **kwargs): # ... # Paste his hack right after the `module` try/catch. # Override BaseFCGIServer.error to use Django error handling. # http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L1210 def patch_error(self, req): import sys from django.conf import settings from django.core import urlresolvers from django.core.handlers.wsgi import WSGIRequest urlconf = settings.ROOT_URLCONF urlresolvers.set_urlconf(urlconf) resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) # No access to 'environ' so rebuild WSGIRequest. # http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L1077 environ = req.params environ.update(self.environ) environ['wsgi.version'] = (1,0) environ['wsgi.input'] = req.stdin self._sanitizeEnv(environ) wsgireq = WSGIRequest(environ) # http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py#L177 response = self.application.handle_uncaught_exception(wsgireq, resolver, sys.exc_info()) # TODO: NGINX figures this out, but other servers might not. # http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L1104 req.stdout.write('Status: 500\r\n') req.stdout.write('Content-Type: text/html\r\n\r\n' + response.content) WSGIServer.error = patch_error </code></pre> <p>Now you can enjoy Django stack traces even for flup level errors!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload