运行适用于Windows 7的Gearman时出错

时间:2014-01-20 07:46:44

标签: python perl gearman python-gearman

您好我在Windows 7中安装了perl的gearman软件包,并编写了简单的客户端和工作人员,以便连接到gearman服务器,如下所示:

Client.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和clients(在cygwin和gearman 0.14下正常工作)来反转字符串,但它显示了相同的错误。

我的Python模块是:

Client.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_”。

有人可以解决这个问题吗?

0 个答案:

没有答案