PHPKonf ─░stanbul PHP Conference 2015



(PECL gearman >= 0.5.0)

GearmanClient::jobStatus -- gearman_job_statusGet the status of a background job


Stile orientato agli oggetti (method):

public array GearmanClient::jobStatus ( string $job_handle )

Gets the status for a background job given a job handle. The status information will specify whether the job is known, whether the job is currently running, and the percentage completion.

Elenco dei parametri


L'handle de job assegnato dal server Gearman

Valori restituiti

An array containing status information for the job corresponding to the supplied job handle. The first array element is a boolean indicating whether the job is even known, the second is a boolean indicating whether the job is still running, and the third and fourth elements correspond to the numerator and denominator of the fractional completion percentage, respectively.


Example #1 Monitor the status of a long running background job


/* create our object */
$gmclient= new GearmanClient();

/* add the default server */

/* run reverse client */
$job_handle $gmclient->doBackground("reverse""this is a test");

if (
$gmclient->returnCode() != GEARMAN_SUCCESS)
"bad return code\n";

$done false;
$stat $gmclient->jobStatus($job_handle);
   if (!
$stat[0]) // the job is known so it is not done
$done true;
"Running: " . ($stat[1] ? "true" "false") . ", numerator: " $stat[2] . ", denomintor: " $stat[3] . "\n";



Il precedente esempio visualizzerà qualcosa simile a:

Running: true, numerator: 3, denomintor: 14
Running: true, numerator: 6, denomintor: 14
Running: true, numerator: 9, denomintor: 14
Running: true, numerator: 12, denomintor: 14
Running: false, numerator: 0, denomintor: 0

Vedere anche:

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top