[Twisted-Python] Nested/Aggregate Exceptions

Justin Mazzola Paluska jmp at TWIN-TOWERS.MIT.EDU
Tue Mar 28 08:52:59 EST 2006


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
across PB.  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?


More information about the Twisted-Python mailing list