summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/news.txt3
-rw-r--r--paste/debug/profile.py9
2 files changed, 10 insertions, 2 deletions
diff --git a/docs/news.txt b/docs/news.txt
index 228bc9d..bd0b39a 100644
--- a/docs/news.txt
+++ b/docs/news.txt
@@ -44,6 +44,9 @@ svn trunk
* ``StackedObjectProxy`` supports ``__call__``.
+* Fixed ``ProfileMiddleware`` not calling ``close()`` on consumed
+ app_iters.
+
1.3
---
diff --git a/paste/debug/profile.py b/paste/debug/profile.py
index cf4f085..fcf943c 100644
--- a/paste/debug/profile.py
+++ b/paste/debug/profile.py
@@ -27,7 +27,7 @@ class ProfileMiddleware(object):
The data is isolated to that single request, and does not include
data from previous requests.
- This uses the ``hotshot`` module, which effects performance of the
+ This uses the ``hotshot`` module, which affects performance of the
application. It also runs in a single-threaded mode, so it is
only usable in development environments.
"""
@@ -51,7 +51,12 @@ class ProfileMiddleware(object):
start_response(status, headers, exc_info)
return body.append
def run_app():
- body.extend(self.app(environ, replace_start_response))
+ app_iter = self.app(environ, replace_start_response)
+ try:
+ body.extend(app_iter)
+ finally:
+ if hasattr(app_iter, 'close'):
+ app_iter.close()
self.lock.acquire()
try:
prof = hotshot.Profile(self.log_filename)