(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[TracebackType],
)
| 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: |
no test coverage detected