code: async def _run_server_task(self, started_signal):
          
  
          try:
              server = await websockets.serve(self._manage_connection, self.host, self.port)
              port = server.sockets[0].getsockname()[1]
              started_signal.set_result(port)
          except Exception as err:
              self._logger.exception("Error starting server on host %s, port %s", self.host, self.port)
              started_signal.set_exception(err)
              return
  
          try:
              while True:
                  await asyncio.sleep(1)
          except asyncio.CancelledError:
              self._logger.info("Stopping server due to stop() command")
          finally:
              server.close()
              await server.wait_closed()
  
          self._logger.debug("Server stopped, exiting task")
docs: Create a BackgroundTask to manage the server.
  
          This allows subclasess to attach their server related tasks as
          subtasks that are properly cleaned up when this parent task is
          stopped and not require them all to overload start() and stop()
          to perform this action.