[GIS] Clean way to cancel QGIS processing scripts from gui

pyqgisqgisqgis-processing

I've written a QGIS processing script that carries out a closest facility analysis. Taking the complete input data set (20k adresses as start points, ~100 target points, OSM road network with ~13k linestrings) the script runs about 3 hours, and therefore makes use of various progress indicators, to make shure to the user that it's still alive (log output, progress bar, time remaining, rubber bands indication the way to closest facililty just processed, cp. screenshot below):

enter image description here

Now I would like to cancel the running script and as far as I can see, this can only be done with [X] top right in the processing script gui window.

But doing so, the script remains processing as indicated by the blue rubber bands as well as the processing time and the progress bar…

enter image description here

enter image description here

… and the system resources in the task manager:

enter image description here

enter image description here

However, couple of minutes (~14min) later on the script stops processing and the system is not consuming anymore resources:

enter image description here

enter image description here

enter image description here

Since the time span between closing the window and stopping processing seems fairly unpredictable to me, my question is: Is this a recommended way to cancel QGIS processing scripts, or are there other ways to cleanly cancelling such scripts from the gui?

Best Answer

From command shell, "taskkill /f /im qgis-ltr-bin.exe /t" would terminate the process immediately. I don't think there's a gui solution, based on what you're going for though. In QGIS, if you wanted to end the process cleanly, you'd have to wait for the program when ending the process. But via command shell this would allow you to move forward right away.

Related Question