Sets a callback that will be run when the connection is closed. Note that this callback is slightly different from `.HTTPMessageDelegate.on_connection_close`: The `.HTTPMessageDelegate` method is called when the connection is closed while receiving a message. This ca
(self, callback: Optional[Callable[[], None]])
| 315 | self.stream.set_close_callback(None) |
| 316 | |
| 317 | def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None: |
| 318 | """Sets a callback that will be run when the connection is closed. |
| 319 | |
| 320 | Note that this callback is slightly different from |
| 321 | `.HTTPMessageDelegate.on_connection_close`: The |
| 322 | `.HTTPMessageDelegate` method is called when the connection is |
| 323 | closed while receiving a message. This callback is used when |
| 324 | there is not an active delegate (for example, on the server |
| 325 | side this callback is used if the client closes the connection |
| 326 | after sending its request but before receiving all the |
| 327 | response. |
| 328 | """ |
| 329 | self._close_callback = callback |
| 330 | |
| 331 | def _on_connection_close(self) -> None: |
| 332 | # Note that this callback is only registered on the IOStream |
no outgoing calls
no test coverage detected