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

Encapsulates a task to be executed, and executes it in another thread. More...

Inheritance diagram for task.task.Task:

Public Member Functions

def __init__ (self, fn, *args, **kwargs)
 
def start (self, withqrunnable=True)
 
def run (self)
 
def callback (self, *args, **kwargs)
 
def getId (self)
 

Public Attributes

 signals
 
 fn
 
 args
 
 kwargs
 
 id
 

Static Public Attributes

 idgenerator = itertools.count()
 

Detailed Description

Encapsulates a task to be executed, and executes it in another thread.

Provides a quick way to execute long running procedures in a separate thread. If the user may choose, they can set up connections to signals that are triggered in specific circumstances.

Inherits from QRunnable to handle task 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::

task = Task(function_to_execute)
task.signals.result.connect(function_to_publish_result)
task.signals.finished.connect(function_when_finished)
task.start()

The start() method requests a common QThreadPool to execute this object.

Note
This class is intended to simplify threading, and is in no way a complete replacement for all situations.

Constructor & Destructor Documentation

◆ __init__()

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

Member Function Documentation

◆ callback()

def task.task.Task.callback (   self,
args,
**  kwargs 
)

◆ getId()

def task.task.Task.getId (   self)

◆ run()

def task.task.Task.run (   self)

◆ start()

def task.task.Task.start (   self,
  withqrunnable = True 
)

Member Data Documentation

◆ args

task.task.Task.args

◆ fn

task.task.Task.fn

◆ id

task.task.Task.id

◆ idgenerator

task.task.Task.idgenerator = itertools.count()
static

◆ kwargs

task.task.Task.kwargs

◆ signals

task.task.Task.signals

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