我正在尝试运行一个简单的Pyro示例(taken from this page),这是代码:
import Pyro.core
import Pyro.naming
class JokeGen(Pyro.core.ObjBase):
def joke(self, name):
return "Sorry "+name+", I don't know any jokes."
daemon=Pyro.core.Daemon()
ns=Pyro.naming.NameServerLocator().getNS()
daemon.useNameServer(ns)
uri=daemon.connect(JokeGen(),"jokegen")
daemon.requestLoop()
当我使用Python 2.6.5和Python 2.6.6(在Ubuntu 10.04和Debian Squeeze上都试过)运行此脚本时,我总是收到此错误:
Traceback (most recent call last):
File "/home/ingo/tools/python/pyroserver.py", line 9, in <module>
ns=Pyro.naming.NameServerLocator().getNS()
File "/usr/lib/pymodules/python2.6/Pyro/naming.py", line 176, in getNS
reply = self.sendSysCommand(NS_SYSCMD_LOCATION,host,port,trace,1,bcaddr)
File "/usr/lib/pymodules/python2.6/Pyro/naming.py", line 76, in sendSysCommand
raise Pyro.errors.NamingError("could not find NameServer")
Pyro.errors.NamingError: could not find NameServer
脚本有什么问题?我该如何创建该名称服务器?
答案 0 :(得分:4)
首先在另一个终端中运行pyro-ns
。那是Pyro对象经纪人。