def _handle_connection(self):
        # type: () -> None
        """
        Handles one incoming connection.
        """
        assert self._connection is not None
        try:
            self._connection.settimeout(1)
            self._connection.sendall(b'Activating maintenance mode, waiting for other actions to complete ...\n')
            self._activate()
            self._connection.sendall(b'Connected\n')
            while self._maintenance_communicator.is_active():
                try:
                    try:
                        data = self._connection.recv(1024)
                        if not data:
                            logger.info('Stopping maintenance mode due to no data.')
                            break
                        if data.startswith(b'exit'):
                            logger.info('Stopping maintenance mode due to exit.')
                            break

                        self._maintenance_communicator.write(data.decode())
                    except Exception as exception:
                        if System.handle_socket_exception(self._connection, exception, logger):
                            continue
                        else:
                            logger.exception('Unexpected exception receiving connection data')
                            break
                except Exception:
                    logger.exception('Exception in maintenance mode')
                    break
        except InMaintenanceModeException:
            self._connection.sendall(b'Maintenance mode already active.\n')
        finally:
            self._deactivate()
            logger.info('Maintenance mode deactivated')
            self._connection.close()
            self._connection = None