def connection_made(self, chan: Any) -> None:
        """
        Client connected, run repl in coroutine.
        """
        self._chan = chan

        # Run REPL interface.
        f = asyncio.ensure_future(self.repl.run_async())

        # Close channel when done.
        def done(_: object) -> None:
            chan.close()
            self._chan = None

        f.add_done_callback(done)

        Client connected, run repl in coroutine.
        
src/ptpython/contrib/asyncssh_repl.py