[Twisted-Python] Nested/Aggregate Exceptions
johann.borck at densedata.com
Tue Mar 28 19:59:53 EST 2006
Justin Mazzola Paluska wrote:
>I'm writing a Twisted application using Twisted 2.0.1 on Mandriva 2006
>that uses PerspectiveBroker for communication between modules. Our
>application is based on a centralized Twisted server and web- and
>GTK-based client applications that connect to the Twisted server to
>manage a user database.
>Up until recently, most of methods exported by the Twisted server are
>essentially single-operation functions that operate on a single user
>(e.g., "update_user(user, **data)"). As such, exception handling in
>the clients is easy: if the operation throws an exception, we know
>what operation died and can report a reasonable error to the user
>running the client program.
>In the most recent version of our server, however, we've decided to
>add several aggregate functions to our server that take in multiple
>users (e.g., "update_users(users, **data)" where users is a Python
>list of user names). Essentially, these new aggregate functions
>repeatedly call their single-operation counterparts multiple times.
>Since each call that the aggregate function makes is independent from
>other calls, we store away exceptions that get raised and continue
>with the other operations. At the end of the function, if there were
>errors, we raise an AggregateException that contains the list of all
>exceptions raised by the aggregate function. This way our clients
>know what the specific exceptions and what arguments they failed on.
>The problem is, I can't figure out how to pass an AggregateException
You only want to pass information about what went wrong and how, why do
you have to transmit the exceptions themselves? Isn't it even more
efficient to just submit the relevant info? As far as I know PB takes a
set of classes which are allowed to be transmitted, and anything else
including unexpected Exceptions won't be. maybe there's already some
kind of exception-handling in PB, but iirc (though vaguely a phrase in
the docs like) "you have to care about Exceptions yourself".
> I know I can probably use pb.CopyableFailure, but my
>experiments usually died when I passed non-Failure-subclasses into my
>aggregate. Do the mavens on the list have any suggestions?
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
More information about the Twisted-Python