def kvs_watch_wrapper(key, value, arg, errnum): (callback, real_arg) = ffi.from_handle(arg) if errnum == errno.ENOENT: value = None else: value = json.loads(ffi.string(value)) key = ffi.string(key) ret = callback(key, value, real_arg, errnum) return ret if ret is not None else 0
def get_key_direct(flux_handle, key): valp = ffi.new('char *[1]') RAW.flux_kvs_get(flux_handle, key, valp) if valp[0] == ffi.NULL: return None else: return json.loads(ffi.string(valp[0]))
def watch_once(flux_handle, key): """ Watches the selected key until the next change, then returns the updated value of the key """ if isdir(flux_handle, key): directory = get_dir(flux_handle) # The wrapper automatically unpacks directory's handle RAW.flux_kvs_watch_once_dir(flux_handle, directory) return directory else: out_json_str = ffi.new('char *[1]') RAW.flux_kvs_watch_once(flux_handle, key, out_json_str) if out_json_str[0] == ffi.NULL: return None else: return json.loads(ffi.string(out_json_str[0]))
def __next__(self): ret = RAW.flux_kvsitr_next(self.itr) if ret is None or ret == ffi.NULL: raise StopIteration() return ffi.string(ret)
def key_at(self, key): c_str = self.pimpl.key_at(key) p_str = ffi.string(c_str) lib.free(c_str) return p_str