def is_closing ( self ) -> bool : return self . stream . closed ( ) or self . client_terminated or self . server_terminated
python how to tell if a socket is closed
Return True if this connection is closing .
def is_closing(self) -> bool:
        """Return ``True`` if this connection is closing.

        The connection is considered closing if either side has
        initiated its closing handshake or if the stream has been
        shut down uncleanly.
        """
        return self.stream.closed() or self.client_terminated or self.server_terminated