PyRO:daemon.connect(PyroObj,name) - >不起作用

时间:2014-04-12 16:16:37

标签: python pyro

我遇到了PyRO的问题,这很奇怪,因为 pyro-ns(名称服务器)正在运行 。所以请看下面的错误:

[127.0.0.1] out: name server <Pyro.naming.NameServerProxy object at 0x1983990>
[127.0.0.1] out: Traceback (most recent call last):
[127.0.0.1] out:   File "/var/tmp/UINX_rileva_temperatura.py", line 72, in <module>
[127.0.0.1] out:     __avvia_pyro_server(cpu, cpu_name, event)
[127.0.0.1] out:   File "/var/tmp/UINX_rileva_temperatura.py", line 58, in __avvia_pyro_server
[127.0.0.1] out:     URI = daemon.connect(PyroObj, name)
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/core.py", line 696, in connect
[127.0.0.1] out:     self.NameServer.register(name, URI)
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/naming.py", line 229, in register
[127.0.0.1] out:     return self.__remoteinvoc('register',0,_expandName(name),URI)
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/naming.py", line 213, in __remoteinvoc
[127.0.0.1] out:     return self.adapter.remoteInvocation(*args)
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/protocol.py", line 457, in remoteInvocation
[127.0.0.1] out:     return self._remoteInvocation(method, flags, *args)
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/protocol.py", line 532, in _remoteInvocation
[127.0.0.1] out:     answer.raiseEx()
[127.0.0.1] out:   File "/usr/lib/pymodules/python2.7/Pyro/errors.py", line 72, in raiseEx
[127.0.0.1] out:     raise self.excObj
[127.0.0.1] out: Pyro.errors.NamingError: ('(parent)group not found', ':Default.127.0.0')

Disconnecting from 127.0.0.1...

现在代码 ..非常简单。

class CPU(Pyro.core.ObjBase):


    def __init__(self):

        Pyro.core.ObjBase.__init__(self)  ## init for the master class 


    def close_pyro_server(self):

        event.set() ## i'm not using this, but it's useful to close this pyro server (not pyro name server!)


def __start_pyro_server(PyroObj, event):

            Pyro.core.initServer() 
            daemon = Pyro.core.Daemon()
            name_server = Pyro.naming.NameServerLocator().getNS() #locate the pyro name server
            print 'name server ' + str(name_server)
            daemon.useNameServer(name_server) #daemon use the pyro name server found

            URI = daemon.connect(PyroObj, name) ## <---- doesn't work !! it would connect an object (child of Pyro.core.ObjBase) with a common name, like 'my_object', it's useful to retrieve the object easily
            daemon.requestLoop(condition = lambda event: False if event.is_set() == True else True) ## pyro server start to work
            daemon.close() ## when the server is out of the loop, let's close it




if __name__ == '__main__':  
    event = threading.Event()
    cpu = CPU()
    __start_pyro_server(cpu, event)

1 个答案:

答案 0 :(得分:0)

答案是远程对象名称为&#39; 192.168.0.1&#39;无法工作。所以我必须避免使用点,逗号等。