1.4. gearman.job — Gearman job definitions

1.4.1. GearmanJob - Basic information about a requested job

class gearman.job.GearmanJob(connection, handle, task, unique, data)[source]

Represents the basics of a job... used in GearmanClient / GearmanWorker to represent job states

1.4.1.1. Server identifers

GearmanJob.connection

GearmanConnection - Server assignment. Could be None prior to client job submission

GearmanJob.handle

string - Job’s server handle. Handles are NOT interchangeable across different gearman servers

1.4.1.2. Job parameters

GearmanJob.task

string - Job’s task

GearmanJob.unique

string - Job’s unique identifier (client assigned)

GearmanJob.data

binary - Job’s binary payload

1.4.2. GearmanJobRequest - State tracker for requested jobs

class gearman.job.GearmanJobRequest(gearman_job, initial_priority=None, background=False, max_attempts=1)[source]

Represents a job request... used in GearmanClient to represent job states

1.4.2.1. Tracking job submission

GearmanJobRequest.gearman_job

GearmanJob - Job that is being tracked by this GearmanJobRequest object

GearmanJobRequest.priority
  • PRIORITY_NONE [default]
  • PRIORITY_LOW
  • PRIORITY_HIGH
GearmanJobRequest.background

boolean - Is this job backgrounded?

GearmanJobRequest.connection_attempts

integer - Number of attempted connection attempts

GearmanJobRequest.max_connection_attempts

integer - Maximum number of attempted connection attempts before raising an exception

1.4.2.2. Tracking job progress

GearmanJobRequest.result

binary - Job’s returned binary payload - Populated if and only if JOB_COMPLETE

GearmanJobRequest.exception

binary - Job’s exception binary payload

GearmanJobRequest.state
  • JOB_UNKNOWN - Request state is currently unknown, either unsubmitted or connection failed
  • JOB_PENDING - Request has been submitted, pending handle
  • JOB_CREATED - Request has been accepted
  • JOB_FAILED - Request received an explicit job failure (job done but errored out)
  • JOB_COMPLETE - Request received an explicit job completion (job done with results)
GearmanJobRequest.timed_out

boolean - Did the client hit its polling_timeout prior to a job finishing?

GearmanJobRequest.complete[source]

boolean - Does the client need to continue to poll for more updates from this job?

1.4.2.3. Tracking in-flight job updates

Certain GearmanJob’s may send back data prior to actually completing. GearmanClient uses these queues to keep track of what/when we received certain updates.

GearmanJobRequest.warning_updates

collections.deque - Job’s warning binary payloads

GearmanJobRequest.data_updates

collections.deque - Job’s data binary payloads

GearmanJobRequest.status

dictionary - Job’s status

  • handle - string - Job handle
  • known - boolean - Is the server aware of this request?
  • running - boolean - Is the request currently being processed by a worker?
  • numerator - integer
  • denominator - integer
  • time_received - integer - Time last updated

New in version 2.0.1: Replaces GearmanJobRequest.status_updates and GearmanJobRquest.server_status

GearmanJobRequest.status_updates

Deprecated since version 2.0.1: Replaced by GearmanJobRequest.status

GearmanJobRequest.server_status

Deprecated since version 2.0.1: Replaced by GearmanJobRequest.status