#!/usr/bin/python

from gearman import libgearman

def work(job):
    workload = job.get_workload()
    if workload == 'fail':
        job.send_fail()
    return workload

gm_worker = libgearman.Worker()
gm_worker.add_server('localhost')
gm_worker.add_function('print', work)

while True:
    gm_worker.work()
