Added python script for testing
This commit is contained in:
parent
da43d2efe5
commit
2d62a1d5d1
13
example/py/client.py
Executable file
13
example/py/client.py
Executable 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
21
example/py/worker.py
Executable 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()
|
||||||
|
|
@ -3,7 +3,7 @@ package gearman
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"log"
|
// "log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type jobClient struct {
|
type jobClient struct {
|
||||||
@ -44,7 +44,6 @@ func (client *jobClient) Work() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println(string(rel))
|
|
||||||
job, err := DecodeWorkerJob(rel)
|
job, err := DecodeWorkerJob(rel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.worker.ErrQueue <- err
|
client.worker.ErrQueue <- err
|
||||||
|
Loading…
Reference in New Issue
Block a user