1
0
mirror of https://github.com/django/django.git synced 2025-10-26 23:26:08 +00:00

Switch to using context managers for acquiring and releasing locks.

This commit is contained in:
Alex Gaynor
2012-06-23 08:11:15 -07:00
parent e1b74d0094
commit e0fce8706d
6 changed files with 28 additions and 57 deletions

View File

@@ -210,8 +210,7 @@ class WSGIHandler(base.BaseHandler):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
self.initLock.acquire()
try:
with self.initLock:
try:
# Check that middleware is still uninitialised.
if self._request_middleware is None:
@@ -220,8 +219,6 @@ class WSGIHandler(base.BaseHandler):
# Unload whatever middleware we got
self._request_middleware = None
raise
finally:
self.initLock.release()
set_script_prefix(base.get_script_name(environ))
signals.request_started.send(sender=self.__class__)