Call the given callback when the stream is closed. This mostly is not necessary for applications that use the `.Future` interface; all outstanding ``Futures`` will resolve with a `StreamClosedError` when the stream is closed. However, it is still useful as a way to s
(self, callback: Optional[Callable[[], None]])
| 550 | return future |
| 551 | |
| 552 | def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None: |
| 553 | """Call the given callback when the stream is closed. |
| 554 | |
| 555 | This mostly is not necessary for applications that use the |
| 556 | `.Future` interface; all outstanding ``Futures`` will resolve |
| 557 | with a `StreamClosedError` when the stream is closed. However, |
| 558 | it is still useful as a way to signal that the stream has been |
| 559 | closed while no other read or write is in progress. |
| 560 | |
| 561 | Unlike other callback-based interfaces, ``set_close_callback`` |
| 562 | was not removed in Tornado 6.0. |
| 563 | """ |
| 564 | self._close_callback = callback |
| 565 | self._maybe_add_error_listener() |
| 566 | |
| 567 | def close( |
| 568 | self, |