Write data to transport, handling connection errors gracefully. Catches exceptions that occur when the client has disconnected: - OSError with errno EPIPE, ECONNRESET, ENOTCONN - RuntimeError when transport is closing/closed - AttributeError when transport is None
(self, data)
| 728 | self._flow_control.resume_writing() |
| 729 | |
| 730 | def _safe_write(self, data): |
| 731 | """Write data to transport, handling connection errors gracefully. |
| 732 | |
| 733 | Catches exceptions that occur when the client has disconnected: |
| 734 | - OSError with errno EPIPE, ECONNRESET, ENOTCONN |
| 735 | - RuntimeError when transport is closing/closed |
| 736 | - AttributeError when transport is None |
| 737 | |
| 738 | These are silently ignored since the client is already gone. |
| 739 | """ |
| 740 | try: |
| 741 | self.transport.write(data) |
| 742 | except OSError as e: |
| 743 | if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN): |
| 744 | self.log.exception("Socket error writing response.") |
| 745 | except (RuntimeError, AttributeError): |
| 746 | # Transport is closing/closed or None |
| 747 | pass |
| 748 | |
| 749 | async def _handle_connection(self): |
| 750 | """Main request handling loop using callback-based parser. |
no test coverage detected