I tried to run the example gearman client and workers. Gearman worker never seems to be woken up. I see the following message when I kill the gearman worker and I don't see the output at the worker(print statements)
File "gearman_w.py", line 12, in worker.work() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gearman/worker.py", line 160, in work rd, wr, ex = select.select([c for c in alive if c.readable()], [], alive, 10) KeyboardInterruptalive, 10) KeyboardInterrupt
It seems to be waiting on select and never woken up. Am I missing something?
I use macosx, python 2.7 installed via ports. The code I used is below
Gearman Client
import sys
import time
from gearman import GearmanClient, Task
client = GearmanClient(["127.0.0.1"])
i = 0
while 1:
client.dispatch_background_task('speak', i)
print 'Dispatched %d' % i
i += 1
time.sleep(1)
Gearman Worker
import time
from gearman import GearmanWorker
def speak(job):
r = 'Hello %s' % job.arg
print r
return r
worker = GearmanWorker("[127.0.0.1]")
worker.register_function('speak', speak)
worker.work()
On another note select.poll() doesn't seem to work either(when trying out beanstalk with python) though this link says installing macports version should work doesn't help either