Open dnephin opened 10 years ago
This may be helpful: https://github.com/Yelp/python-gearman/issues/61#issuecomment-58848342
Ok, if I understood well it says to send the GEARMAN_COMMAND_GET_STATUS command that answers with a message like this: {'known': '1', 'numerator': '0', 'running': '1', 'denominator': '0', 'job_handle': 'H:lab-vm12:2266'} But it only says if there is a job running, and after the worker has finished it turns to: {'known': '0', 'numerator': '0', 'running': '0', 'denominator': '0', 'job_handle': 'H:lab-vm12:2266'} So I cannot reach the resulting data. Is there a command such as "GEARMAN_COMMAND_GET_WORKING_DATA" that I can send to the gearman server to obtain the job result?
@lidio601
The easiest way to handle this with background jobs is to use job_handle as a key in an alternative storage engine and then looking the data up there if known==0, running==0 and you're sure that the job has existed (use job_handle for that).
Unfortunately GET_STATUS responses will say known==0 && running==0 for both jobs that have finished and jobs that never existed in the first place. This goes beyond the use case of Gearman, use alternative storage in your application to keep track of it and populate the key there (job_handle) with the status msgs that you want to access later.
@lidio601
WORK_STATUS is only for non-background jobs. With background jobs you have to substitute Gearman's WORK_STATUS. I think the Gearman daemon even drops the status of background jobs entirely once executed.
looking at http://pythonhosted.org/gearman/client.html#retrieving-job-status there does not appear to be any way to get the result of a background job. Waiting on status complete does not work because "complete" for a background job is when it receives it.