rrefutil: add trap_deafref utility, to make the callRemote-plus-ignore-DeadReferenceError-plug-log-other-errors pattern easier

This commit is contained in:
Brian Warner 2009-06-22 19:08:26 -07:00
parent 699510c8f1
commit aa23ff9180

View File

@ -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