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