Pyro4: Could not find name server

I am new to Python and Pyro4. So I try to follow the second example of this Pyro page - Python Remote Objects - 4.41 , but this is the exception when starting the server:

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

Code Server:

# 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 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

First run pyro-ns at the other end:

$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.

Note: I am working on Debian 8 and I installed:

to run this example

Maybe I missed something. Any ideas why this doesn't work, or the things I'm doing wrong? thanks in advance.

+4
source share
2

:

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, ,

+6

, python 3 python 2 , , "pyro4" "python2-pyro4". , python 3, - python 2.

pyro-ns, , , .

0

Source: https://habr.com/ru/post/1622002/


All Articles