0

I'm totally new to RPC and Pyro and trying to understand the consept of it.I'm doing the example of website of it and my code isn't working when I do ns=True despite it's working when ns=False.I'am getting this error:

Pyro4.errors.NamingError: Failed to locate the nameserver

When I debug with ipdb,I see this:

CommunicationError: cannot connect: [Errno 111] Connection refused

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()

what is the solution of not starting the daemon?

2 Answers2

0

The ns=True argument in serveSimple will register the objects in a running nameserver somewhere. You'll have to start that by yourself. It won't work if there's no name server already running.

Irmen de Jong
  • 2,739
  • 1
  • 14
  • 26
0

You need to read the instructions carefully on the tutorial. You need to run python -m Pyro4.naming outside of warehouse.py

Luis
  • 1,828
  • 2
  • 19
  • 27