2

I have the following setup: Pyro nameserver running under python2.7, Pyro daemon running under python2.7, and (ideally) a Pyro client running python3.3.

If I connect to the server using a client running under python2.7 everything works fine. When using python3.3 for the client I can create the proxy connection just fine, but I get:

Traceback (most recent call last):                                                                                                                     
  File "<stdin>", line 1, in <module>                                                                                                                  
  File "/project_path/lib/python3.3/site-packages/Pyro4/core.py", line 149, 
    return self.__send(self.__name, args, kwargs)                                                                                                      
  File "/project_path/lib/python3.3/site-packages/Pyro4/core.py", line 271, 
    self.__pyroCreateConnection()                                                                                                                      
  File "/project_path/lib/python3.3/site-packages/Pyro4/core.py", line 322, 
    uri=resolve(self._pyroUri)                                                                                                                         
  File "/project_path/lib/python3.3/site-packages/Pyro4/naming.py", line 336
    nameserver=locateNS(uri.host, uri.port)                                                                                                            
  File "/project_path/lib/python3.3/site-packages/Pyro4/naming.py", line 274
    proxy.ping()                                                                                                                                       
  File "/project_path/lib/python3.3/site-packages/Pyro4/core.py", line 149, 
    return self.__send(self.__name, args, kwargs)                                                                                                      
  File "/project_path/lib/python3.3/site-packages/Pyro4/core.py", line 290, 
    data=self._pyroSerializer.deserialize(data, compressed=flags & MessageFactory.FLAGS_COMPRESSED)                    
  File "/project_path/lib/python3.3/site-packages/Pyro4/util.py", line 146, 
    return self.pickle.loads(data)                                                                                                                     
ImportError: No module named 'exceptions'       

when trying to use any remote methods. The pyro docs seem to imply that I should be able to interconnect python2.7 instances with python3.3, is this not the case?

Both the 2.7 and 3.3 instance of python are using Pyro4 version 4.16

EDIT: Here's some actual code that's not working for me:

(With a python2 ns started)

In a python2.7 virtualenv:

import Pyro4

class TestProxy(object):       

    def foo(self):             
        return "bar"           

if __name__ == "__main__":     

    print "* Starting test proxy"   
    daemon=Pyro4.Daemon()
    tproxy_uri=daemon.register(TestProxy())
    ns=Pyro4.locateNS()
    ns.register("foo",tproxy_uri)   

    print "* Proxy started"
    daemon.requestLoop()

and in a python3.3 virtualenv:

import Pyro4

rtest = Pyro4.Proxy("PYRONAME:foo")
print(rtest.foo())

I get that exact exception I put above.

Mediocre Gopher
  • 2,274
  • 1
  • 22
  • 39
  • In the end I said screw it and ported the project back to python2.7. But I'm still curious about the answer to this problem if anyone knows it. – Mediocre Gopher Dec 25 '12 at 01:24

2 Answers2

2

The reason is pickle. It is the „protocol” used for exchanging object over the network. That's why you cannot pass classes, but only objects and so on. Pickle for py3 has major changes, but 2.7 vs. 2.6 does not. So, in theory, pyro will work between 2.6 > 2.7, but not 2.7 > 3.3. (it works, I have a VPS with python 2.6 and I am force to move client app on my comp on py2.7 too.) Probably a hack at pickle module may avoid the error, but I am sure that will open a pandora box. The only „real” alternative is to use a python server, over http/socket/https (not necesarly a web server) and send/recive serialized strings/commands.

P.S.: I see that the post is old!

cox
  • 731
  • 5
  • 12
1

What cox said is right. Pickle are different between python2,3. But serpent seems to be compatible. You can try

PYRO_SERIALIZERS_ACCEPTED=serpent /usr/bin/python3 -Wignore -m Pyro4.naming

sih4sing5hog5
  • 180
  • 11