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)
 
def run (self)
 Perform the actual task of this job. More...
 
str getMessage (self)
 
None setMessage (self, str message)
 
Any getResult (self)
 Get the result of the job. More...
 
def setResult (self, Any result)
 Set the result of this job. More...
 
None setError (self, Exception error)
 Set an exception that was thrown while the job was being executed. More...
 
None start (self)
 Start the job. More...
 
None cancel (self)
 Cancel the job. More...
 
bool isRunning (self)
 Check whether the job is currently running. More...
 
bool isFinished (self)
 Check whether the job has finished processing. More...
 
bool hasError (self)
 Check whether the Job has encountered an error during execution. More...
 
Exception getError (self)
 Get the error that was encountered during execution. More...
 

Static Public Member Functions

None 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

Member Function Documentation

◆ cancel()

None 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.

◆ getError()

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

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

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

bool UM.Job.Job.isFinished (   self)

Check whether the job has finished processing.

Returns
bool

◆ isRunning()

bool UM.Job.Job.isRunning (   self)

Check whether the job is currently running.

Returns
bool

◆ run()

def UM.Job.Job.run (   self)

Perform the actual task of this job.

Should be reimplemented by subclasses.

Exceptions
NotImplementedError

Reimplemented in UM.Scene.Platform._LoadPlatformJob, UM.FileHandler.WriteFileJob.WriteFileJob, UM.FileHandler.ReadFileJob.ReadFileJob, and UM.Mesh.ReadMeshJob.ReadMeshJob.

◆ setError()

None UM.Job.Job.setError (   self,
Exception  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,
Any  result 
)

Set the result of this job.

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

◆ start()

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

None 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: