summaryrefslogtreecommitdiff
path: root/paste
diff options
context:
space:
mode:
Diffstat (limited to 'paste')
-rw-r--r--paste/deploy/config.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/paste/deploy/config.py b/paste/deploy/config.py
index 11f3921..766e5d9 100644
--- a/paste/deploy/config.py
+++ b/paste/deploy/config.py
@@ -156,19 +156,21 @@ class ConfigMiddleware(object):
conf = environ['paste.config'] = self.config.copy()
app_iter = None
CONFIG.push_thread_config(conf)
+ popped_config = False
try:
app_iter = self.application(environ, start_response)
finally:
if app_iter is None:
# An error occurred...
CONFIG.pop_thread_config(conf)
+ popped_config = True
if type(app_iter) in (list, tuple):
# Because it is a concrete iterator (not a generator) we
# know the configuration for this thread is no longer
# needed:
CONFIG.pop_thread_config(conf)
return app_iter
- else:
+ elif not popped_config:
def close_config():
CONFIG.pop_thread_config(conf)
new_app_iter = wsgilib.add_close(app_iter, close_config)