MCPcopy
hub / github.com/tornadoweb/tornado / close

Method close

tornado/iostream.py:560–606  ·  view source on GitHub ↗

Close this stream. 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`).

(
        self,
        exc_info: Union[
            None,
            bool,
            BaseException,
            Tuple[
                "Optional[Type[BaseException]]",
                Optional[BaseException],
                Optional[TracebackType],
            ],
        ] = False,
    )

Source from the content-addressed store, hash-verified

558 self._maybe_add_error_listener()
559
560 def close(
561 self,
562 exc_info: Union[
563 None,
564 bool,
565 BaseException,
566 Tuple[
567 "Optional[Type[BaseException]]",
568 Optional[BaseException],
569 Optional[TracebackType],
570 ],
571 ] = False,
572 ) -> None:
573 """Close this stream.
574
575 If ``exc_info`` is true, set the ``error`` attribute to the current
576 exception from `sys.exc_info` (or if ``exc_info`` is a tuple,
577 use that instead of `sys.exc_info`).
578 """
579 if not self.closed():
580 if exc_info:
581 if isinstance(exc_info, tuple):
582 self.error = exc_info[1]
583 elif isinstance(exc_info, BaseException):
584 self.error = exc_info
585 else:
586 exc_info = sys.exc_info()
587 if any(exc_info):
588 self.error = exc_info[1]
589 if self._read_until_close:
590 self._read_until_close = False
591 self._finish_read(self._read_buffer_size)
592 elif self._read_future is not None:
593 # resolve reads that are pending and ready to complete
594 try:
595 pos = self._find_read_pos()
596 except UnsatisfiableReadError:
597 pass
598 else:
599 if pos is not None:
600 self._read_from_buffer(pos)
601 if self._state is not None:
602 self.io_loop.remove_handler(self.fileno())
603 self._state = None
604 self.close_fd()
605 self._closed = True
606 self._signal_closed()
607
608 def _signal_closed(self) -> None:
609 futures = [] # type: List[Future]

Callers 12

read_until_regexMethod · 0.95
read_untilMethod · 0.95
_handle_eventsMethod · 0.95
_handle_readMethod · 0.95
_read_to_bufferMethod · 0.95
_handle_writeMethod · 0.95
close_fdMethod · 0.45
connectMethod · 0.45
_handle_connectMethod · 0.45
_do_ssl_handshakeMethod · 0.45
close_fdMethod · 0.45
read_from_fdMethod · 0.45

Calls 8

closedMethod · 0.95
_finish_readMethod · 0.95
_find_read_posMethod · 0.95
_read_from_bufferMethod · 0.95
filenoMethod · 0.95
close_fdMethod · 0.95
_signal_closedMethod · 0.95
remove_handlerMethod · 0.45

Tested by

no test coverage detected