class _QueuedJob(object):
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 a _QueuedJob from serialized state: |
Method | __init__ |
Constructor for the _QueuedJob. |
Method | __repr__ |
Undocumented |
Method |
|
Extend the reason trail |
Method |
|
Gets the current priority for this job. |
Method |
|
Compute the status of this job. |
Method |
|
Marks job as canceled/-ing if possible. |
Method |
|
Changes the job priority. |
Method |
|
Marks the job as finalized. |
Method |
|
Selectively returns the log entries. |
Method |
|
Mark unfinished opcodes with a given status and result. |
Method |
|
Serialize the _JobQueue instance. |
Method |
|
Sets the job's process ID |
Class Variable | __slots__ |
Undocumented |
Instance Variable | archived |
Undocumented |
Instance Variable | end |
the timestamp for end of execution |
Instance Variable | id |
the job ID |
Instance Variable | livelock |
Undocumented |
Instance Variable | log |
holds the index for the next log entry |
Instance Variable | ops |
the list of _QueuedOpCode that constitute the job |
Instance Variable | process |
Undocumented |
Instance Variable | queue |
the parent queue |
Instance Variable | received |
the timestamp for when the job was received |
Instance Variable | start |
Undocumented |
Instance Variable | start |
the timestamp for start of execution |
Instance Variable | writable |
Whether the job is allowed to be modified |
Static Method | _ |
Initializes in-memory variables. |
Restore a _QueuedJob from serialized state:
Parameters | |
queue:JobQueue | to which queue the restored job belongs |
state:dict | the serialized state |
writable:bool | Whether job can be modified |
archived:bool | Whether job was already archived |
Returns | |
_JobQueue | the restored _JobQueue instance |
Constructor for the _QueuedJob.
Parameters | |
queue:JobQueue | our parent queue |
job | our job id |
ops:list | the list of opcodes we hold, which will be encapsulated in _QueuedOpCodes |
writable:bool | Whether job can be modified |
Gets the current priority for this job.
Only unfinished opcodes are considered. When all are done, the default priority is used.
Returns | |
int | Undocumented |
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 |
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 |
Changes the job priority.
Parameters | |
priority:int | New priority |
Returns | |
tuple; (bool, string) | Boolean describing whether job's priority was successfully changed and a text message |
Selectively returns the log entries.
Parameters | |
newer | if this is None, return all log entries, otherwise return only the log entries with serial higher than this value |
Returns | |
list | the list of the log entries selected |