Skip to content

Instantly share code, notes, and snippets.

@anarcher
Created May 4, 2009 12:46
Show Gist options
  • Save anarcher/106454 to your computer and use it in GitHub Desktop.
Save anarcher/106454 to your computer and use it in GitHub Desktop.
gearman
from gearman import GearmanClient
from gearman.task import Task
JOB_SERVER = ['127.0.0.1:4730']
if __name__ == '__main__':
client = GearmanClient(JOB_SERVER)
ret3 = client.do_task(Task("hello","task...",timeout=1))
print ret3
ret = client("hello","world")
print ret
ret2 = client("hello","hahaha")
print ret2
gearman -f hello 'world'
gearman -f hello 'world' 'korea' 'seoul'
from gearman import GearmanWorker
from gearman.manager import GearmanManager
JOB_SERVER = ['127.0.0.1:4730']
if __name__ == '__main__':
manager = GearmanManager(JOB_SERVER[0])
print manager.status()
from gearman import GearmanWorker
def hello(job):
return "Hello, %s \r\n" % job.arg
if __name__ == '__main__':
worker = GearmanWorker(['127.0.0.1:4730'])
worker.register_function('hello',hello)
worker.work()
from gearman import GearmanWorker
from multiprocessing import Pool
from multiprocessing import Process
def hello(job):
return "Hello, %s \r\n" % job.arg
if __name__ == '__main__':
for i in range(4):
w = GearmanWorker(['127.0.0.1:4730'])
w.register_function('hello',hello)
Process(target=w.work).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment