Skip to content

Instantly share code, notes, and snippets.

@nloadholtes
Created April 5, 2012 14:41
Show Gist options
  • Save nloadholtes/2311553 to your computer and use it in GitHub Desktop.
Save nloadholtes/2311553 to your computer and use it in GitHub Desktop.
Gearman 2.x worker example
#
# worker.py
#
# Based on code from http://www.darkcoding.net/software/choosing-a-message-queue-for-python-on-ubuntu-on-a-vps/
#
import time
from gearman import GearmanWorker
def speakTask(gearman_worker, job):
r = 'Hello %s' % job.data
print(r)
return r
worker = GearmanWorker("[127.0.0.1]")
worker.register_task('speak', speakTask)
worker.work()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment