diff options
author | pjenvey <devnull@localhost> | 2007-05-04 19:33:11 +0000 |
---|---|---|
committer | pjenvey <devnull@localhost> | 2007-05-04 19:33:11 +0000 |
commit | 28824c0b52205627436c36c8716d8d897ece746c (patch) | |
tree | d4df72ec7804c6f3683ce752306a289660406d62 /paste/debug/profile.py | |
parent | 8a944a7ae64e2d7ddc12fb2c5da1eb2805dd0a07 (diff) | |
download | paste-28824c0b52205627436c36c8716d8d897ece746c.tar.gz |
o make ProfileMiddleware close the consumed app_iter if applicable
fixes "Error: app_iter.close() was not called when finishing WSGI request."
o spelling
Diffstat (limited to 'paste/debug/profile.py')
-rw-r--r-- | paste/debug/profile.py | 9 |
1 files changed, 7 insertions, 2 deletions
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) |