嗨,我在 Windows 7 中安装了 perl 的 gearman 包,并编写了简单的客户端和 worker 来连接到 gearman 服务器,如下所示:
客户端.pl
use Gearman::Client;
my $client = Gearman::Client->new;
$client->job_servers('127.0.0.1:7003');
和Worker.pl
use Gearman::Worker;
my $worker = Gearman::Worker->new;
$worker->job_servers('127.0.0.1:7003');
$worker->work while 1;
但是当我运行worker.pl时,gearmand的命令提示符给出错误,因为 接受传入连接时出错:文件描述符错误
我还尝试使用 python worker 和客户端(在 cygwin 和 gearman 0.14 下正常工作)来反转字符串,但它显示相同的错误。
我的 Python 模块是:
客户端.py
import gearman
def check_request_status(job_request):
if job_request.complete:
print "Job %s finished! Result: %s - %s" % (job_request.job.unique, job_request.state, job_request.result)
elif job_request.timed_out:
print "Job %s timed out!" % job_request.unique
elif job_request.state == JOB_UNKNOWN:
print "Job %s connection failed!" % job_request.unique
gm_client = gearman.GearmanClient(['127.0.0.1:7003'])
completed_job_request = gm_client.submit_job("reverse", "Hello World!")
check_request_status(completed_job_request)
和worker.py
import gearman
gm_worker = gearman.GearmanWorker(['127.0.0.1:7003'])
def task_listener_reverse(gearman_worker, gearman_job):
print 'Reversing string: ' + gearman_job.data
return gearman_job.data[::-1]
# gm_worker.set_client_id is optional
gm_worker.set_client_id('python-worker')
gm_worker.register_task('reverse', task_listener_reverse)
# Enter our work loop and call gm_worker.after_poll() after each time we timeout/see socket activity
gm_worker.work()
当我运行 Client.pl gearmand 命令提示符时,错误如下:
错误:无法通过 C:/Perl/site/lib/Gearman/Server/Client.pm 第 505 行的包“Gearman::Server::Client”找到对象方法“CMD_”。
有人可以解决这个问题吗?