class documentation

class _QueuedJob(object):

View In Hierarchy

In-memory job representation.

This is what we use to track the user-submitted jobs. Locking must be taken care of by users of this class.

Class Method Restore Restore a _QueuedJob from serialized state:
Method __init__ Constructor for the _QueuedJob.
Method __repr__ Undocumented
Method AddReasons Extend the reason trail
Method CalcPriority Gets the current priority for this job.
Method CalcStatus Compute the status of this job.
Method Cancel Marks job as canceled/-ing if possible.
Method ChangePriority Changes the job priority.
Method Finalize Marks the job as finalized.
Method GetLogEntries Selectively returns the log entries.
Method MarkUnfinishedOps Mark unfinished opcodes with a given status and result.
Method Serialize Serialize the _JobQueue instance.
Method SetPid Sets the job's process ID
Class Variable __slots__ Undocumented
Instance Variable archived Undocumented
Instance Variable end_timestamp the timestamp for end of execution
Instance Variable id the job ID
Instance Variable livelock Undocumented
Instance Variable log_serial holds the index for the next log entry
Instance Variable ops the list of _QueuedOpCode that constitute the job
Instance Variable process_id Undocumented
Instance Variable queue the parent queue
Instance Variable received_timestamp the timestamp for when the job was received
Instance Variable start_timestamp Undocumented
Instance Variable start_timestmap the timestamp for start of execution
Instance Variable writable Whether the job is allowed to be modified
Static Method _InitInMemory Initializes in-memory variables.
@classmethod
def Restore(cls, queue, state, writable, archived):

Restore a _QueuedJob from serialized state:

Parameters
queue:JobQueueto which queue the restored job belongs
state:dictthe serialized state
writable:boolWhether job can be modified
archived:boolWhether job was already archived
Returns
_JobQueuethe restored _JobQueue instance
def __init__(self, queue, job_id, ops, writable):

Constructor for the _QueuedJob.

Parameters
queue:JobQueueour parent queue
job_id:job_idour job id
ops:listthe list of opcodes we hold, which will be encapsulated in _QueuedOpCodes
writable:boolWhether job can be modified
def __repr__(self):

Undocumented

def AddReasons(self, pickup=False):

Extend the reason trail

Add the reason for all the opcodes of this job to be executed.

def CalcPriority(self):

Gets the current priority for this job.

Only unfinished opcodes are considered. When all are done, the default priority is used.

Returns
intUndocumented
def CalcStatus(self):

Compute the status of this job.

This function iterates over all the _QueuedOpCodes in the job and based on their status, computes the job status.

The algorithm is:

  • if we find a cancelled, or finished with error, the job status will be the same

  • otherwise, the last opcode with the status one of:

    • waitlock
    • canceling
    • running

    will determine the job status

  • otherwise, it means either all opcodes are queued, or success, and the job status will be the same

Returns
the job status
def Cancel(self):

Marks job as canceled/-ing if possible.

Returns
tuple; (bool, string)Boolean describing whether job was successfully canceled or marked as canceling and a text message
def ChangePriority(self, priority):

Changes the job priority.

Parameters
priority:intNew priority
Returns
tuple; (bool, string)Boolean describing whether job's priority was successfully changed and a text message
def Finalize(self):

Marks the job as finalized.

def GetLogEntries(self, newer_than):

Selectively returns the log entries.

Parameters
newer_than:None or intif this is None, return all log entries, otherwise return only the log entries with serial higher than this value
Returns
listthe list of the log entries selected
def MarkUnfinishedOps(self, status, result):

Mark unfinished opcodes with a given status and result.

This is an utility function for marking all running or waiting to be run opcodes with a given status. Opcodes which are already finalised are not changed.

Parameters
statusa given opcode status
resultthe opcode result
def Serialize(self):

Serialize the _JobQueue instance.

Returns
dictthe serialized state
def SetPid(self, pid):

Sets the job's process ID

Parameters
pid:intthe process ID
__slots__: list[str] =

Undocumented

archived: bool =

Undocumented

end_timestamp =

the timestamp for end of execution

id =

the job ID

livelock =

Undocumented

log_serial: int =

holds the index for the next log entry

ops: list =

the list of _QueuedOpCode that constitute the job

process_id =

Undocumented

queue: JobQueue =

the parent queue

received_timestamp =

the timestamp for when the job was received

start_timestamp =

Undocumented

start_timestmap =

the timestamp for start of execution

writable =

Whether the job is allowed to be modified

@staticmethod
def _InitInMemory(obj, writable):

Initializes in-memory variables.