Re: Raising custom exceptions on remote objects

Irmen de Jong <[email protected]> Sat, 28 Feb 2015 02:03:13 +0100
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 27-2-2015 9:46, Mathis Gavillon wrote:
> Hi,
> 
> I try to develop an application using Pyro4 for remote objects.
> I need that my shared objects can be able to raise custom exceptions (neither Pyro4
> exceptions nor builtins exceptions). I use some libraries that raises their own exceptions.
> 
> 
> From client side, when one of these exceptions are raised, Pyro raises another one :
> "Pyro4.errors.ProtocolError: unsupported serialized class: libvirt.libvirtError" is one
> example.
> 
> I look into util Pyro4 module (dict_to_class method of SerizalizerBase class) which
> seems that only builtins and Pyro exceptions are supported.

Yup, all other exceptions usually are instances of a custom class.
You have to teach Pyro (or rather, the serpent serializer) how to deal with them.
See
http://pythonhosted.org/Pyro4/clientcode.html#changing-the-way-your-custom-classes-are-de-serialized

Alternatively, catch them and rethrow as one of the builtin exception types in your Pyro
object.

If all that fails, but please avoid this, switch to using the pickle serializer. That
deals with custom types just fine but at a security cost.


Irmen


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/