Class: QgsBlockingProcess

class qgis.core.QgsBlockingProcess(program: str, arguments: Iterable[str])

Bases: PyQt5.QtCore.QObject

Constructor for the given program, with the specified list of arguments.

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

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.

New in version 3.18.

Parameters
  • program (str) –

  • arguments

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
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)