From aa23ff91807370434b2442a52ecdbfd84a8d019d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 22 Jun 2009 19:08:26 -0700 Subject: [PATCH] rrefutil: add trap_deafref utility, to make the callRemote-plus-ignore-DeadReferenceError-plug-log-other-errors pattern easier --- src/allmydata/util/rrefutil.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.45.2