From 2d62a1d5d1fc778aaf26c0acad5a0629f6043331 Mon Sep 17 00:00:00 2001 From: mikespook Date: Sun, 22 May 2011 23:02:03 +0800 Subject: [PATCH] Added python script for testing --- example/py/client.py | 13 +++++++++++++ example/py/worker.py | 21 +++++++++++++++++++++ src/pkg/gearman/worker/jobclient.go | 3 +-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 example/py/client.py create mode 100755 example/py/worker.py diff --git a/example/py/client.py b/example/py/client.py new file mode 100755 index 0000000..18c9d38 --- /dev/null +++ b/example/py/client.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +from gearman import libgearman + +def main(): + client = libgearman.Client() + client.add_server("127.0.0.1", 4730) + r = client.do("ToUpper", "arbitrary binary data") + print r + +if __name__ == '__main__': + main() + diff --git a/example/py/worker.py b/example/py/worker.py new file mode 100755 index 0000000..d6cb7b8 --- /dev/null +++ b/example/py/worker.py @@ -0,0 +1,21 @@ +#!/usr/bin/python +import time + +from gearman import libgearman + + +def toUpper(job): + r = job.get_workload().upper() + print r + return r + +def main(): + worker = libgearman.Worker() + worker.add_server("127.0.0.1", 4730) + worker.add_function("ToUpper", toUpper) + while True: + worker.work() + +if __name__ == '__main__': + main() + diff --git a/src/pkg/gearman/worker/jobclient.go b/src/pkg/gearman/worker/jobclient.go index 5ab0546..ae49374 100644 --- a/src/pkg/gearman/worker/jobclient.go +++ b/src/pkg/gearman/worker/jobclient.go @@ -3,7 +3,7 @@ package gearman import ( "net" "os" - "log" +// "log" ) type jobClient struct { @@ -44,7 +44,6 @@ func (client *jobClient) Work() { break } } - log.Println(string(rel)) job, err := DecodeWorkerJob(rel) if err != nil { client.worker.ErrQueue <- err