Dispatching caught exceptions
Gerhard Häring
gerhard.haering at gmx.de
Fri Dec 6 16:47:14 EST 2002
Gerson Kurz wrote:
> I've written a small mixin class that can be used to synchronize
> member function calls by enclosing the actual function call in a
> mutex acquire/release block. The class reads as follows:
> [snip]
I remember writing such a thing myself :)
> OK, but sometimes I want a thus synchronized function to throw an
> exception anyway? What I'm looking for thus is something like
>
> try:
> ...
> except anything:
> # store exception "anything" somewhere
> self.mutex.release()
> raise exception
>
> This seems like really simple stuff, but I cannot find it. (Maybe
> because I don't like exceptions anyway?)
You need try: ... finally:
try:
...
finally:
self.mutex.release()
-- Gerhard
More information about the Python-list
mailing list