【问题标题】:Pyro ns=True not workingPyron ns=True 不工作
【发布时间】:2015-03-28 04:01:16
【问题描述】:

我对 RPC 和 Pyro 完全陌生,并试图理解它的概念。我正在做它的网站示例,当我做 ns=True 时我的代码不起作用,尽管它在 ns= 时工作错误。我收到此错误:

Pyro4.errors.NamingError: 未能找到名称服务器

当我使用 ipdb 进行调试时,我看到:

CommunicationError:无法连接:[Errno 111] 连接被拒绝

from __future__ import print_function
import Pyro4
import person

class Warehouse(object):
    def __init__(self):
        self.contents = ["chair", "bike", "flashlight", "laptop", "couch"]

    def list_contents(self):
        return self.contents

    def take(self, name, item):
        self.contents.remove(item)
        print("{0} took the {1}.".format(name, item))

    def store(self, name, item):
        self.contents.append(item)
        print("{0} stored the {1}.".format(name, item))

def main():
    warehouse = Warehouse()
    Pyro4.Daemon.serveSimple(
            {
                warehouse: "example.warehouse"
            },
            ns = True)

if __name__=="__main__":
    main()

不启动守护进程的解决方法是什么?

【问题讨论】:

    标签: python rpc pyro


    【解决方案1】:

    serveSimple 中的 ns=True 参数将在某处运行的名称服务器中注册对象。你必须自己开始。如果没有名称服务器已经在运行,它将无法工作。

    【讨论】:

      【解决方案2】:

      您需要仔细阅读教程中的说明。 您需要在warehouse.py 之外运行python -m Pyro4.naming

      【讨论】:

        猜你喜欢
        • 2016-04-09
        • 2019-05-02
        • 2018-04-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多