Run Webserver Start as a QGIS Background Task
Starting the embedded webserver currently blocks the QGIS UI thread for several seconds. This makes the plugin appear “frozen” during startup, which is confusing for end-users (especially non-technical staff).
QGIS provides a built-in mechanism for running long-running or blocking code in the background via QgsTask. Using a background task keeps the UI responsive and allows for clean progress or status messaging.
Proposed Solution
Move the webserver startup into a QGIS background task, similar to the existing Topology Check implementation:
def run_server_in_background(self) -> None:
self.task = QgsTask.fromFunction(
description="XMAS Webserver Start",
function=self._start_server,
on_finished=self._on_server_started,
)
Reference: https://qgis.org/pyqgis/master/core/QgsTask.html#qgis.core.QgsTask.fromFunction
The task should:
- Execute the (blocking) server startup in the background
- Return success or failure back to the UI thread cleanly
- Optionally show a toast/notification (“Webserver started successfully”)
- Show user-friendly error feedback in case of failures
- Integrate with the existing task system used for
run_topo_check_in_background
Acceptance Criteria
- QGIS remains fully responsive while the webserver starts
- No visible UI freeze or stutter
- Server starts reliably as before
- Clear success/error feedback to the user
- Code style matches the existing background task pattern