MCPcopy Create free account
hub / github.com/EasyIME/PIME / _handle_exception

Method _handle_exception

python/python3/tornado/simple_httpclient.py:544–578  ·  view source on GitHub ↗
(
        self,
        typ: "Optional[Type[BaseException]]",
        value: Optional[BaseException],
        tb: Optional[TracebackType],
    )

Source from the content-addressed store, hash-verified

542 self.io_loop.add_callback(final_callback, response)
543
544 def _handle_exception(
545 self,
546 typ: "Optional[Type[BaseException]]",
547 value: Optional[BaseException],
548 tb: Optional[TracebackType],
549 ) -> bool:
550 if self.final_callback:
551 self._remove_timeout()
552 if isinstance(value, StreamClosedError):
553 if value.real_error is None:
554 value = HTTPStreamClosedError("Stream closed")
555 else:
556 value = value.real_error
557 self._run_callback(
558 HTTPResponse(
559 self.request,
560 599,
561 error=value,
562 request_time=self.io_loop.time() - self.start_time,
563 start_time=self.start_wall_time,
564 )
565 )
566
567 if hasattr(self, "stream"):
568 # TODO: this may cause a StreamClosedError to be raised
569 # by the connection's Future. Should we cancel the
570 # connection more gracefully?
571 self.stream.close()
572 return True
573 else:
574 # If our callback has already been called, we are probably
575 # catching an exception that is not caused by us but rather
576 # some child of our callback. Rather than drop it on the floor,
577 # pass it along, unless it's just the stream being closed.
578 return isinstance(value, StreamClosedError)
579
580 def on_connection_close(self) -> None:
581 if self.final_callback is not None:

Callers 4

runMethod · 0.95
_on_timeoutMethod · 0.95
_write_bodyMethod · 0.95
on_connection_closeMethod · 0.95

Calls 6

_remove_timeoutMethod · 0.95
_run_callbackMethod · 0.95
HTTPResponseClass · 0.90
timeMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected