Class: QgsBlockingProcess

class qgis.core.QgsBlockingProcess

Bases: PyQt5.QtCore.QObject

A thread safe class for performing blocking (sync) execution of external processes.

This class should be used whenever a blocking process run is required. Unlike implementations which rely on QApplication.processEvents() or creation of a QEventLoop, this class is completely thread safe and can be used on either the main thread or background threads without issue.

Not available on some platforms (e.g. iOS) https://lists.qt-project.org/pipermail/development/2015-July/022205.html

New in version 3.18.

QgsBlockingProcess(program: str, arguments: Iterable[str]) Constructor for the given program, with the specified list of arguments.

After construction, call run() to start the process execution.

Methods

childEvent

connectNotify

customEvent

disconnectNotify

exitStatus

After a call to run(), returns the process’ exit status.

isSignalConnected

processError

After a call to run(), returns the process’ reported error.

receivers

run

Runs the process, and blocks until execution finishes.

sender

senderSignalIndex

setStdErrHandler

Sets a handler function to call whenever content is written by the process to stderr.

setStdOutHandler

Sets a handler function to call whenever content is written by the process to stdout.

timerEvent

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
exitStatus(self)QProcess.ExitStatus

After a call to run(), returns the process’ exit status.

Return type

QProcess.ExitStatus

isSignalConnected(self, QMetaMethod)bool
processError(self)QProcess.ProcessError

After a call to run(), returns the process’ reported error.

Returns QProcess.UnknownError if no error occurred.

Return type

QProcess.ProcessError

receivers(self, PYQT_SIGNAL)int
run(self, feedback: QgsFeedback = None)int

Runs the process, and blocks until execution finishes.

The optional feedback argument can be used to specify a feedback object for cancellation/process termination.

After execution completes, the process’ result code will be returned.

Parameters

feedback (QgsFeedback = None) –

Return type

int

sender(self)QObject
senderSignalIndex(self)int
setStdErrHandler(self, Callable[..., None])

Sets a handler function to call whenever content is written by the process to stderr.

setStdOutHandler(self, Callable[..., None])

Sets a handler function to call whenever content is written by the process to stdout.

timerEvent(self, QTimerEvent)