python – Pyro4:找不到名称服务器
发布时间:2020-12-30 10:25:22  所属栏目:Python  来源:互联网 
            导读:我是 Python和Pyro4的新手.所以我尝试按照此页面 Pyro – Python Remote Objects – 4.41的第二个示例,但是当我运行服务器时抛出此异常: Traceback (most recent call last): File greeting-server.py, line 10, in module ns = Pyro4.locateNS()
                
                
                
            | 
                         我是 Python和Pyro4的新手.所以我尝试按照此页面 Pyro – Python Remote Objects – 4.41的第二个示例,但是当我运行服务器时抛出此异常: Traceback (most recent call last):
  File "greeting-server.py",line 10,in <module>
    ns = Pyro4.locateNS()                  # find the name server
  File "/usr/lib/python2.7/dist-packages/Pyro4/naming.py",line 344,in locateNS
    raise e
Pyro4.errors.NamingError: Failed to locate the nameserver 
 代码服务器: # saved as greeting-server.py
import Pyro4
class GreetingMaker(object):
    def get_fortune(self,name):
        return "Hello,{0}. Here is your fortune message:n" 
               "Tomorrow's lucky number is 12345678.".format(name)
daemon = Pyro4.Daemon()                # make a Pyro daemon
ns = Pyro4.locateNS()                  # find the name server
uri = daemon.register(GreetingMaker)   # register the greeting maker as a Pyro object
ns.register("example.greeting",uri)   # register the object with a name in the name server
print("Ready.")
daemon.requestLoop()                   # start the event loop of the server to wait for calls 
 首先在另一个终端运行pyro-ns: $pyro-ns
*** Pyro Name Server ***
Name server listening on: ('0.0.0.0',9090)
WARNING: daemon bound on hostname that resolves to loopback address 127.0.x.x 
URI is: PYRO://127.0.1.1:9090/7f0001011d2a21ca9fb63702dd216e1143
URI written to: /home/guille/Documents/pyro examples/Pyro4-master/examples/banks/Pyro_NS_URI
Name Server started. 
 备注:我在Debian 8上工作,我安装了: > sudo apt-get install pyro4 运行这个例子 也许我错过了什么.任何想法为什么这不起作用,或者我做错了什么? 解决方法这项工作对我来说:首先在另一个终端运行python -m Pyro4.naming: Not starting broadcast server for localhost. NS running on localhost:9090 (127.0.0.1) URI = PYRO:Pyro.NameServer@localhost:9090 而不是pyro-ns我之前为pyro4做过,因为你看到这个程序改变了 (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
相关内容
- 在python日志记录中使用dictConfig,需要创建一个不同于在di
 - python – 从整个熊猫数据帧返回最大值,而不是基于列或行
 - python – 编写一个通用的getattr()并根据attr名称填充方法
 - 处理django包含模板标记中的请求
 - python – Pandas:更改具有多级列的数据框中的特定列名称
 - import next()python 2.5
 - Python 检查数组元素是否存在类似PHP isset()方法
 - 使用Python在OpenOffice / Microsoft Word中格式化输出
 - python – 改变seaborn heatmap颜色条上的刻度尺寸
 - python – 如何动态调用类中的方法使用方法名分配给变量
 
