This forum has been archived. Please start a new discussion on GitHub.

Python: serialize ice proxy to save into redis database

josedavid Toledo
edited December 2019 in Comments


I have an Ice Application implemented in Python and I use icestorm to connect different endpoints.

Currently, I keep the proxy of endpoints in app memory and when any endpoints wants to connect with another, I simply create the topic in icestorm.

Now, I want to save the proxies in a redis as part of one class instance but I can't do it using json.dumps or pickle.dumps since the proxy is not a standard type.

  • JSON library: throws a TypeError (object is not json serializable) when I try to dumps the object in a JSON.
  • pickle library: save action its ok but throws a RuntimeError ('A proxy cannot be created directly) when I try to loads from redis.

Is there any way to serialize and deserialize the proxy in redis using python? I don't care if I have to create a string or json manually, serializing and deserializing the proxy manually in some way.



  • xdm
    xdm La Coruña, Spain


    You can use ice_toString to convert the proxy to a string and then communicator.stringToProxy(...) to convert it back the string to a proxy, you might also need uncheckedCast to get the correct proxy type.

    serialized = prx.ice_toString()
    prx = FooPrx.uncheckedCast(communicator.stringToProxy(serialized))
  • Hi,

    The solution provided is valid.