Uranium
Application Framework
Loading...
Searching...
No Matches
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

 __init__ (self)
 
 run (self)
 Perform the actual task of this job.
 
 getResult (self)
 Get the result of the job.
 
 setResult (self, any result)
 Set the result of this job.
 
 setError (self, Exception error)
 Set an exception that was thrown while the job was being executed.
 
 start (self)
 Start the job.
 
 cancel (self)
 Cancel the job.
 
bool isRunning (self)
 Check whether the job is currently running.
 
bool isFinished (self)
 Check whether the job has finished processing.
 
bool hasError (self)
 Check whether the Job has encountered an error during execution.
 
Exception getError (self)
 Get the error that was encountered during execution.
 

Static Public Member Functions

 yieldThread ()
 Utility function that allows us to yield thread processing.
 

Static Public Attributes

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

Protected Attributes

 _running
 
 _finished
 
 _result
 
 _error
 

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

UM.Job.Job.__init__ (   self)

Member Function Documentation

◆ cancel()

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

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

UM.Job.Job.run (   self)

Perform the actual task of this job.

Should be reimplemented by subclasses.

Exceptions
NotImplementedError

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

◆ setError()

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

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

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

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: