2

I have a problem with QGIS 3.6.0 on macos and QGIS3.2.3 on Windows7 with running processing scripts and models in background. According to QGIS3 docs they are run in background thread by default (if there is no FlagNoThreading flag defined.

Unfortunately there is no "run in background" button on processing dialog (just "Run") and they are run in main GUI thread (or in other thread but blocking GUI anyway).

I couldn't find any QGIS configuration setting for this. What could be the reason for QGIS3 to run them in GUI-blocking mode?

  • Is your Windows7 OS 32 or 64 bit? – klewis Jun 12 at 16:23
3

I'm going to answer my own question because I just solved the issue myself.

The issue is only with models, not scripts and is caused by this line in QGIS3 code.

QgsProcessingAlgorithm::Flags QgsProcessingModelAlgorithm::flags() const
{
    // TODO - check child algorithms, if they all support threading, then the model supports threading...
    return QgsProcessingAlgorithm::flags() | QgsProcessingAlgorithm::FlagNoThreading;
}

It adds FlagNoThreading flag by default and in each and every case to the model-based algorithm. So every model runs in main GUI thread by default and you can't change that as a QGIS3 user.

The solution is to use "Export Model as Python algorithm ..." option, save the model as processing .py script and run it as a script. It runs in background just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.