In QGIS 3 I am trying to run Processing algorithms in a worker thread in a QGIS plugin (not a Processing plugin) using processing.run, and experience crashes.

I guess I need to provide a QgsProcessingContext when running algorithms, but have not found a way to get a proper one.

mycontext = QgsProcessingContext()    
inpbuff = processing.run("native:buffer", {'INPUT': self.inpvl, 'DISTANCE': radius, 'SEGMENTS': 10, 'END_CAP_STYLE': 0, 'JOIN_STYLE': 0, 'MITER_LIMIT': 1, 'DISSOLVE': True, 'OUTPUT': 'memory:'}, feedback=None, context=mycontext)

Both with and without the context parameter, I get many identical warnings before QGIS crashes:

Warning: QObject::setParent: Cannot set parent, new parent is in a different thread

What is the recommended way of running Processing algorithms in a worker thread in a Plugin in QGIS 3?

  • 1
    I am not sure, if you aren't making this too complex or maybe I didn't get the purpose of the QgsProcessingContext(). Did you check out the syntax in the QGIS Python shell via processing.algorithmHelp("native:buffer")? According to this, I would try something like processing.run('native:buffer', {"INPUT": lineLayer, "DISTANCE": 5, "OUTPUT": resultLayer}) Or maybe the QGIS API break documentation helps? May 24, 2018 at 15:35

1 Answer 1


This seems to have been a problem with early versions of QGIS 3.

With version 3.4.2, I do not get these warnings and crashes when running algorithms in a separate thread in a QGIS plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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