def close(self, exc_info=False):
"""Close this stream.
- If `exc_info` is true, set the `error` attribute to the current
- exception from ``sys.exc_info()``.
+ If ``exc_info`` is true, set the ``error`` attribute to the current
+ exception from `sys.exc_info()` (or if ``exc_info`` is a tuple,
+ use that instead of `sys.exc_info`).
"""
if not self.closed():
- if exc_info and any(sys.exc_info()):
- self.error = sys.exc_info()[1]
+ if exc_info:
+ if not isinstance(exc_info, tuple):
+ exc_info = sys.exc_info()
+ if any(exc_info):
+ self.error = exc_info[1]
if self._read_until_close:
callback = self._read_callback
self._read_callback = None
`Application.add_handlers` call. Now the request will be matched
against the handlers for any ``host_pattern`` that includes the request's
``Host`` header.
+* `IOStream.error` no longer picks up unrelated exceptions.
+* `IOStream.close` now has an ``exc_info`` argument (similar to the
+ one used in the `logging` module) that can be used to set the stream's
+ ``error`` attribute when closing it.