getting_starteddownload> tar xzf gearmand-X.Y.tar.gz
> cd gearmand-X.Y
> ./configure
> make && make install
服务器
> gearmand -d
> gearmand -vv
Worker 使用
> gearman -w -f wc -- wc -l
Client 使用
> gearman -f wc < /etc/passwd
26
脚本使用 py
from gearman import * worker = GearmanWorker(["127.0.0.1"])
def job_run(job) :
return job.arg
worker.register_function("echo",job_run)
worker.work()
|
from gearman import * client = GearmanClient(["127.0.0.1"])
res = client.do_task(Task("echo", "foo")) assert res == "foo"
|
稍微复杂点的:
client = GearmanClient(["127.0.0.1"])
ts = Taskset([
Task(func="echo", arg="foo"),
Task(func="echo", arg="bar"),
])
client.do_taskset(ts)
for task in ts.values():
assert task.result == task.arg
|
阅读(1249) | 评论(0) | 转发(0) |