-1

I have some errors while using gearman in python:

import gearman

gm_worker = gearman.GearmanWorker(['localhost:4730'])

def task_listener_reverse(gearman_worker, gearman_job):
    print d
    print 'Reversing string: ' + gearman_job.data
    return gearman_job.data[::-1]

# gm_worker.set_client_id is optional
gm_worker.set_client_id('python-worker')
gm_worker.register_task('reverse', task_listener_reverse)

# Enter our work loop and call gm_worker.after_poll() after each time we timeout/see socket activity
gm_worker.work()

Here are error in print d, but it is not showing any errors(like NameError: name 'd' is not defined). Failed status returns to gearman client. But on gearman worker no errors is displayed. It's working and receiving new connections

Why does it happen?

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

1 Answers1

0

In Gearman Protocol failed jobs don't have a result.

You can override the "on_job_exception" method on the worker to do whatever logging you'd like. This is the default so you only get a failed job with false

def on_job_exception(self, current_job, exc_info):
    self.send_job_failure(current_job)
    return False

Or you can override it and skip the self.send_job_failure with complete code and the client and look at the result and decide if the result has an error code. But then all jobs will never fail.

Version 1.2

BTW in the 1.2 tree you can do this:

gearmand --exceptions

So that exceptions are enabled on the server. This saves the need for the client to do this.

Kordi
  • 2,405
  • 1
  • 14
  • 13