From 8f532823d0f4946b6db8c670e159a24ecde4db52 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sun, 30 Aug 2015 23:20:45 -0500 Subject: [PATCH] python: neutralize error check for kvsitr This commit adds a method to the FunctionWrapper class to allow users to easily set the error checker for wrapped functions. The same can be done with a number of attribute transformations etc. on the wrapper, but this is a great deal more self documenting. The new method is also used to mark the kvsitr_next function as a cannot-fail function, since its end condition is indistinguishable from failure. --- src/bindings/python/flux/kvs.py | 2 ++ src/bindings/python/flux/wrapper.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/bindings/python/flux/kvs.py b/src/bindings/python/flux/kvs.py index 5a66823214f9..b6016a1f8235 100644 --- a/src/bindings/python/flux/kvs.py +++ b/src/bindings/python/flux/kvs.py @@ -15,6 +15,8 @@ class KVSWrapper(Wrapper): pass _raw = KVSWrapper(ffi, lib, prefixes=['kvs', 'kvs_']) +# override error check behavior for kvsitr_next +_raw.kvsitr_next.set_error_check(lambda x: False) def get_key_direct(flux_handle, key): diff --git a/src/bindings/python/flux/wrapper.py b/src/bindings/python/flux/wrapper.py index efed155a4a5a..5bac46a844c8 100644 --- a/src/bindings/python/flux/wrapper.py +++ b/src/bindings/python/flux/wrapper.py @@ -130,6 +130,9 @@ def __init__(self, fun, name, t, ffi, add_handle=False): 'long long', 'int32_t', 'int64_t')]: self.is_error = lambda x: x < 0 + def set_error_check(self, fun): + self.is_error = fun + def build_argument_translation_list(self, t): alist = t.args[1:] if self.add_handle else t.args for i, a in enumerate(alist, start=1 if self.add_handle else 0):