Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #11193 -- WSGI handler not properly handling lock on er…

…ror in load_middleware. Thanks to Phillip Sitbon.

Backport of [15205] from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit eb9ebb1931de3b41b7cfe9b48e1f7bfa506d3c4e 1 parent 88dfbc5
Andrew Godwin authored January 14, 2011

Showing 1 changed file with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. 14  django/core/handlers/wsgi.py
14  django/core/handlers/wsgi.py
@@ -225,10 +225,16 @@ def __call__(self, environ, start_response):
225 225
         # settings weren't available.
226 226
         if self._request_middleware is None:
227 227
             self.initLock.acquire()
228  
-            # Check that middleware is still uninitialised.
229  
-            if self._request_middleware is None:
230  
-                self.load_middleware()
231  
-            self.initLock.release()
  228
+            try:
  229
+                # Check that middleware is still uninitialised.
  230
+                if self._request_middleware is None:
  231
+                    self.load_middleware()
  232
+            except:
  233
+                # Unload whatever middleware we got
  234
+                self._request_middleware = None
  235
+                raise
  236
+            finally:
  237
+                self.initLock.release()
232 238
 
233 239
         set_script_prefix(base.get_script_name(environ))
234 240
         signals.request_started.send(sender=self.__class__)

0 notes on commit eb9ebb1

Please sign in to comment.
Something went wrong with that request. Please try again.