Uranium
Application Framework
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__ (self, kwargs)
 Initialize. More...
 
def getDescription (self)
 Get the description for this job. More...
 
def isVisible (self)
 Should this job be shown in the UI. More...
 
def run (self)
 Perform the actual task of this job. More...
 
def getResult (self)
 Get the result of the job. More...
 
def setResult (self, result)
 Set the result of this job. More...
 
def setError (self, error)
 Set an exception that was thrown while the job was being executed. More...
 
def start (self)
 Start the job. More...
 
def cancel (self)
 Cancel the job. More...
 
def isRunning (self)
 Check whether the job is currently running. More...
 
def isFinished (self)
 Check whether the job has finished processing. More...
 
def hasError (self)
 Check whether the Job has encountered an error during execution. More...
 
def getError (self)
 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

 finished = Signal()
 Emitted when the job has finished processing. More...
 
 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

◆ __init__()

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

◆ cancel()

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.

◆ getDescription()

def UM.Job.Job.getDescription (   self)

Get the description for this job.

◆ getError()

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.

◆ getResult()

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.

◆ hasError()

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.

◆ isFinished()

def UM.Job.Job.isFinished (   self)

Check whether the job has finished processing.

Returns
bool

◆ isRunning()

def UM.Job.Job.isRunning (   self)

Check whether the job is currently running.

Returns
bool

◆ isVisible()

def UM.Job.Job.isVisible (   self)

Should this job be shown in the UI.

Returns
bool

◆ run()

def UM.Job.Job.run (   self)

Perform the actual task of this job.

Should be reimplemented by subclasses.

Exceptions
NotImplementedError

◆ setError()

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.

◆ setResult()

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.

◆ start()

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

◆ yieldThread()

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

◆ finished

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

Emitted when the job has finished processing.

Parameters
jobJob The finished job.

◆ progress

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: