Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4344092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:50:50+00:00 2026-05-21T11:50:50+00:00

I have a Gearman server running a process which takes a few minutes to

  • 0

I have a Gearman server running a process which takes a few minutes to finish. I’m running a progress bar to show completion, and am attempting to get the percentages for the bar using the Gearman PHP extension and the jobStatus() function.

The job is definitely active and found, as the first two fields (known + still running) return to true. However the third and fourth fields (numerator and denominator of completion percentage) return with nothing. Does anyone know why this might be or how these numbers are computed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:50:51+00:00Added an answer on May 21, 2026 at 11:50 am
    public bool GearmanJob::sendStatus ( int $numerator , int $denominator )
    

    Sends status information to the job
    server and any listening clients. Use
    this to specify what percentage of the
    job has been completed.

    To be able to use it, you will probably also have alter the client a bit to handle the communication.

    Example

    client.php

    <?php
    global $argc,$argv;
    
    if (!file_exists($argv[1])) {
            echo "File not found\n";
            exit(1);
    }
    
    $gmclient= new GearmanClient();
    $gmclient->addServer();
    do
    {
      $result = $gmclient->do("linecount", file_get_contents($argv[1]));
      # Check for various return packets and errors.
    
      switch($gmclient->returnCode())
      {
        case GEARMAN_WORK_STATUS:
          list($numerator, $denominator)= $gmclient->doStatus();
          echo "Status: " . sprintf("%d%%",($numerator/$denominator)*100)
                 . " complete\r";
          break;
        case GEARMAN_SUCCESS:
          break;
      }
    }
    while($gmclient->returnCode() != GEARMAN_SUCCESS);
    
    echo "\nResult: $result\n";
    

    worker.php

    <?php
    $worker= new GearmanWorker();
    $worker->addServer();
    $worker->addFunction("linecount", "linecount");
    while ($worker->work());
    
        function linecount($job)
        {
                $lines = preg_split('/[\r\n]/',
                           $job->workload(),null,PREG_SPLIT_NO_EMPTY);
                $linecount = count($lines);
                $n = 0;
                foreach ($lines as $line) {
                        usleep(3000);
                        $n++;
                        $job->sendStatus($n,$linecount);
                        $ret++;
                }
                return $ret;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table in Sql Server 2008 R2 which contains data stored
I'm running a search application on a FAST ESP server. Now I have this
I have Java code which queries calendar entries from a Lotus Notes Domino server
I have a web server hosted with 1and1 which evidently is hosted in Germany,
I have a MediaWiki running which represents a dictionary of German terms and their
For test purposes I have gearman running on localhost. So I run the gearman
I have page which is redirected from htaccess. now I can pass the German
I want to be able to query a gearman server to determine how many
I have a server with German windows on it, but the DateTime values are
I have noticed a lot of people discussing Gearman and it's scheduling features making

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.