我对 RPC 和 Pyro 完全陌生,并试图理解它的概念。我正在做它的网站示例,当我做 ns=True 时我的代码不起作用,尽管它在 ns=False.I 时工作'收到此错误:
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()
不启动守护进程的解决方案是什么?