SignalManagerFactory

Documentation

qconcurrency.threading_.SignalManagerFactory(signals, queue_stop=None)[source]

Dynamically creates a SignalManager class with all requested signals.

SignalManager objects are dynamically created QtCore.QObject designed to be handed off to a separate thread. They contain a variable number of signals, and the method handle_if_abort which checks the value of self._abort_requested

Example

class SignalManager( QtCore.QObject ):
    returned  = QtCore.Signal()
    exception = QtCore.Signal()

    def handle_if_abort(self):
        if self._abort_requested:
            raise UserCancelledOperation()
Parameters:
  • signals (dict, optional) –

    (ex: {signal_name:emitted datatype(s)} )

    A dictionary of signal-names, and the datatypes they will emit.

    {
        ‘update_status’: None,        # update_status = QtCore.Signal()
        ‘log_message’:  str,          # log_message   = QtCore.Signal(str)
        ‘add_item’:     (int, str),   # add_item      = QtCore.Signal(int, str)
    }
    
  • queue_stop (queue.Queue, optional) – A queue that handles request-aborts. When SignalManager.handle_if_abort is run, if the queue contains this thread’s assigned id, then this thread will be stopped.