plainbox.impl.session.jobs – jobs state handling

This module contains a helper class for associating job state within a particular session. The JobState class holds references to a JobDefinition and JobResult as well as a list of inhibitors that prevent the job from being runnable in a particular session.

class plainbox.impl.session.jobs.JobReadinessInhibitor(cause, related_job=None, related_expression=None)[source]

Class representing the cause of a job not being ready to execute.

It is intended to be consumed by UI layers and to provide them with enough information to render informative error messages or other visual feedback that will aid the user in understanding why a job cannot be started.

There are four possible not ready causes:

UNDESIRED:
This job was not selected to run in this session
PENDING_DEP:
This job depends on another job which was not started yet
FAILED_DEP:
This job depends on another job which was started and failed
PENDING_RESOURCE:
This job has a resource requirement expression that uses a resource produced by another job which was not started yet
FAILED_RESOURCE:
This job has a resource requirement that evaluated to a false value

All causes apart from UNDESIRED use the related_job property to encode a job that is related to the problem. The PENDING_RESOURCE and FAILED_RESOURCE causes also store related_expression that describes the relevant requirement expression.

There are three attributes that can be accessed:

cause:
Encodes the reason why a job is not ready, see above.
related_job:
Provides additional context for the problem. This is not the job that is affected, rather, the job that is causing the problem.
related_expression:
Provides additional context for the problem caused by a failing resource expression.
FAILED_DEP = 2
FAILED_RESOURCE = 4
PENDING_DEP = 1
PENDING_RESOURCE = 3
UNDESIRED = 0
cause_name[source]
class plainbox.impl.session.jobs.JobState(job)[source]

Class representing the state of a job in a session.

Contains two basic properties of each job:

  • the readiness_inhibitor_list that prevent the job form starting
  • the result (outcome) of the run (IJobResult)

For convenience (to SessionState implementation) it also has a reference to the job itself. This class is a pure state holder an will typically collaborate with the SessionState class and the UI layer.

can_start()[source]

Quickly check if the associated job can run right now.

classmethod from_json_record(record)[source]

Create a JobState instance from JSON record

get_readiness_description()[source]

Get a human readable description of the current readiness state

job[source]

the job associated with this state

on_result_changed[source]

Event fired when the result associated with this job state changes

readiness_inhibitor_list

the list of readiness inhibitors of the associated job

result

the result of running the associated job

Previous topic

plainbox.impl.session – session handling

Next topic

plainbox.impl.session.legacy – Legacy suspend/resume API

This Page