summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paste/registry.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/paste/registry.py b/paste/registry.py
index 0c54c18..a575cd3 100644
--- a/paste/registry.py
+++ b/paste/registry.py
@@ -277,13 +277,12 @@ class RegistryManager(object):
try:
app_iter = self.application(environ, start_response)
finally:
- if app_iter is None:
- # An error occurred...
- reg.cleanup()
+ if hasattr(app_iter, 'close'):
+ app_iter.close()
+ # Regardless of if the content is an iterable, generator, list
+ # or tuple, we clean-up right now. If its an iterable/generator
+ # care should be used to ensure the generator has its own ref
+ # to the actual object
+ reg.cleanup()
- # Regardless of if the content is an iterable, generator, list
- # or tuple, we clean-up right now. If its an iterable/generator
- # care should be used to ensure the generator has its own ref
- # to the actual object
- reg.cleanup()
return app_iter