Created
May 4, 2009 12:46
-
-
Save anarcher/106454 to your computer and use it in GitHub Desktop.
gearman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gearman -f hello 'world' | |
gearman -f hello 'world' 'korea' 'seoul' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#gearman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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