From: Brian Warner Date: Tue, 23 Jun 2009 02:08:26 +0000 (-0700) Subject: rrefutil: add trap_deafref utility, to make the callRemote-plus-ignore-DeadReferenceE... X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/frontends/%3C?a=commitdiff_plain;h=aa23ff91807370434b2442a52ecdbfd84a8d019d;p=tahoe-lafs%2Ftahoe-lafs.git rrefutil: add trap_deafref utility, to make the callRemote-plus-ignore-DeadReferenceError-plug-log-other-errors pattern easier --- diff --git a/src/allmydata/util/rrefutil.py b/src/allmydata/util/rrefutil.py index 097e732a..8d2d6c2a 100644 --- a/src/allmydata/util/rrefutil.py +++ b/src/allmydata/util/rrefutil.py @@ -1,5 +1,5 @@ -from foolscap.api import Violation, RemoteException +from foolscap.api import Violation, RemoteException, DeadReferenceError def add_version_to_remote_reference(rref, default): """I try to add a .version attribute to the given RemoteReference. I call @@ -17,3 +17,10 @@ def add_version_to_remote_reference(rref, default): d.addCallbacks(_got_version, _no_get_version) return d +def trap_and_discard(f, *errorTypes): + f.trap(*errorTypes) + pass + +def trap_deadref(f): + f.trap(DeadReferenceError) + pass