Search code examples
pythonpython-2.7picklekeyerrorpyro

KeyError with Pyro4


Im trying to send an object with Pyro4. Seems Like it changes on the way, like Im using pickle.dumps and Pickle.loads on server it works but when I try to use pickle.loads on client it gives me a KeyError.Server:

def get_objects(self,player):
    "Notify player about new game state."
    data = self.player_serialize_gmf(player)
    tst = pickle.dumps("objects %s" % data)
    zzd = pickle.loads(tst)
    return tst

And client calling part :

   data = pickle.loads(self.game.get_objects(self.player))

And the error

  File "/Library/Python/2.7/site-packages/Pyro4-4.40-py2.7.egg/Pyro4/core.py", line 426, in _pyroInvoke
    raise data
KeyError: {u'state': (u'PYRONAME:player.server', (),
                     (u'setLast_ts', u'join', u'setName', u'getNextMove', 
                      u'getPoints', u'getName', u'setNextMove', u'isSpectator', 
                      u'getGj', u'setChar', u'getUuid', u'setPoints', u'setGj', 
                      u'getLast_ts', u'getChar'), (), 0.0, None, u'hello', 0),
                      u'__class__': u'Pyro4.core.Proxy'}

Solution

  • The problem was in server side get_objects() method. I was using primitive and object types in same array. Appearantly they cant be in the same array.

    I hope this will help.