cut  1.2.2-pre1
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
task.workerio.WorkerIO Class Reference

Class that encapsulates a task to be executed. More...

Inheritance diagram for task.workerio.WorkerIO:

Public Member Functions

def __init__ (self, fn, *args, **kwargs)
 
def start (self, withqrunnable=True)
 Initialize the runner function with passed args, kwargs. More...
 
def run (self)
 Initialize the runner function with args, kwargs. More...
 
def callback (self, *args, **kwargs)
 
def getId (self)
 

Public Attributes

 signals
 
 fn
 
 args
 
 kwargs
 
 id
 

Static Public Attributes

 idgenerator = itertools.count()
 

Detailed Description

Class that encapsulates a task to be executed.

Inherits from QRunnable to handle worker thread setup and wrap-up. Since QRunnable is not a QObject, it cannot have signals and slot: Thus, this is delegated to a WorkerSignals class that is owned by the WorkerIO.

In this example, it is shown how to use this class::

worker = WorkerIO(function_to_execute)
worker.result.connect(function_to_publish_result)
worker.finished.connect(function_when_finished)
worker.start()
Note
progress callback is not used, as this requires the method to be called to accept as function argument the callback, and MAL generated methods do not include this. This is useful for other long running tasks.

:param fn: The function callback to run on this worker thread. Supplied args and kwargs will be passed through to the runner. :type fn: function :param args: Arguments to pass to the callback function :param kwargs: Keywords to pass to the callback function

Constructor & Destructor Documentation

◆ __init__()

def task.workerio.WorkerIO.__init__ (   self,
  fn,
args,
**  kwargs 
)

Member Function Documentation

◆ callback()

def task.workerio.WorkerIO.callback (   self,
args,
**  kwargs 
)

◆ getId()

def task.workerio.WorkerIO.getId (   self)

◆ run()

def task.workerio.WorkerIO.run (   self)

Initialize the runner function with args, kwargs.

◆ start()

def task.workerio.WorkerIO.start (   self,
  withqrunnable = True 
)

Initialize the runner function with passed args, kwargs.

Member Data Documentation

◆ args

task.workerio.WorkerIO.args

◆ fn

task.workerio.WorkerIO.fn

◆ id

task.workerio.WorkerIO.id

◆ idgenerator

task.workerio.WorkerIO.idgenerator = itertools.count()
static

◆ kwargs

task.workerio.WorkerIO.kwargs

◆ signals

task.workerio.WorkerIO.signals

The documentation for this class was generated from the following file: