Added python script for testing

This commit is contained in:
mikespook 2011-05-22 23:02:03 +08:00
parent da43d2efe5
commit 2d62a1d5d1
3 changed files with 35 additions and 2 deletions

13
example/py/client.py Executable file
View File

@ -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()

21
example/py/worker.py Executable file
View File

@ -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()

View File

@ -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