File: simpleworker.py

package info (click to toggle)
gearman-interface 0.13.2-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,484 kB
  • ctags: 1,534
  • sloc: sh: 10,756; ansic: 6,769; python: 260; makefile: 126; ruby: 45
file content (16 lines) | stat: -rw-r--r-- 310 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/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()