Uranium
Application Framework
 All Classes Namespaces Files Functions Variables Pages
UM.Job.Job Class Reference

Base class for things that should be performed in a thread. More...

Inheritance diagram for UM.Job.Job:
UM.FileHandler.ReadFileJob.ReadFileJob UM.FileHandler.WriteFileJob.WriteFileJob UM.Scene.Platform._LoadPlatformJob UM.Mesh.ReadMeshJob.ReadMeshJob UM.Mesh.WriteMeshJob.WriteMeshJob

Public Member Functions

def __init__
 Initialize. More...
 
def getDescription
 Get the description for this job. More...
 
def isVisible
 Should this job be shown in the UI. More...
 
def run
 Perform the actual task of this job. More...
 
def getResult
 Get the result of the job. More...
 
def setResult
 Set the result of this job. More...
 
def setError
 Set an exception that was thrown while the job was being executed. More...
 
def start
 Start the job. More...
 
def cancel
 Cancel the job. More...
 
def isRunning
 Check whether the job is currently running. More...
 
def isFinished
 Check whether the job has finished processing. More...
 
def hasError
 Check whether the Job has encountered an error during execution. More...
 
def getError
 Get the error that was encountered during execution. More...
 

Static Public Member Functions

def yieldThread
 Utility function that allows us to yield thread processing. More...
 

Static Public Attributes

tuple finished = Signal()
 Emitted when the job has finished processing. More...
 
tuple progress = Signal()
 Emitted when the job processing has progressed. More...
 

Detailed Description

Base class for things that should be performed in a thread.

The Job class provides a basic interface for a 'job', that is a self-contained task that should be performed in a thread. It makes use of the JobQueue for the actual threading.

See also
JobQueue

Constructor & Destructor Documentation

def UM.Job.Job.__init__ (   self,
  kwargs 
)

Initialize.

Parameters
kwargsKeyword arguments. Possible keywords:
  • description string A short description of the job that can be displayed in the UI. Defaults to an empty string.
  • visible bool True if this job should be shown in the UI, False if not. Defaults to False

Member Function Documentation

def UM.Job.Job.cancel (   self)

Cancel the job.

This will remove the Job from the JobQueue. If the run() function has already been called, this will do nothing.

def UM.Job.Job.getDescription (   self)

Get the description for this job.

def UM.Job.Job.getError (   self)

Get the error that was encountered during execution.

Returns
Exception The error encountered during execution or None if there was no error.
def UM.Job.Job.getResult (   self)

Get the result of the job.

The actual result object returned by this method is dependant on the implementation.

def UM.Job.Job.hasError (   self)

Check whether the Job has encountered an error during execution.

Returns
bool True if an error was set, False if not.
def UM.Job.Job.isFinished (   self)

Check whether the job has finished processing.

Returns
bool
def UM.Job.Job.isRunning (   self)

Check whether the job is currently running.

Returns
bool
def UM.Job.Job.isVisible (   self)

Should this job be shown in the UI.

Returns
bool
def UM.Job.Job.run (   self)

Perform the actual task of this job.

Should be reimplemented by subclasses.

Exceptions
NotImplementedError
def UM.Job.Job.setError (   self,
  error 
)

Set an exception that was thrown while the job was being executed.

Setting error to something else than None implies the Job failed to execute properly.

Parameters
errorException The exception to set.
def UM.Job.Job.setResult (   self,
  result 
)

Set the result of this job.

This should be called by run() to set the actual result of the Job.

def UM.Job.Job.start (   self)

Start the job.

This will put the Job into the JobQueue to be processed whenever a thread is available.

See also
JobQueue::add()
def UM.Job.Job.yieldThread ( )
static

Utility function that allows us to yield thread processing.

This is mostly a workaround for broken python threads. This function forces a GIL release and allows a different thread to start processing if it is waiting.

Member Data Documentation

tuple UM.Job.Job.finished = Signal()
static

Emitted when the job has finished processing.

Parameters
jobJob The finished job.
tuple UM.Job.Job.progress = Signal()
static

Emitted when the job processing has progressed.

Parameters
jobJob The job reporting progress.
amountint The amount of progress made, from 0 to 100.

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