예제 #1
0
파일: kvs.py 프로젝트: SteVwonder/flux-core
def KVSWatchWrapper(key, value, arg, errnum):
    (cb, real_arg) = ffi.from_handle(arg)
    if errnum == errno.ENOENT:
      value = None
    else:
      value = json.loads(ffi.string(value))
    key = ffi.string(key)
    ret = cb(key, value, real_arg, errnum)
    return ret if ret is not None else 0
예제 #2
0
파일: kvs.py 프로젝트: SteVwonder/flux-core
def get_key_direct(flux_handle, key):
    valp = ffi.new('char *[1]')
    _raw.get(flux_handle, key, valp)
    if valp[0] == ffi.NULL:
      return None
    else:
      return json.loads(ffi.string(valp[0]))
예제 #3
0
파일: kvs.py 프로젝트: SteVwonder/flux-core
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):
        d = get_dir(flux_handle)
        # The wrapper automatically unpacks d's handle
        _raw.watch_once_dir(flux_handle, d)
        return d
    else:
        out_json_str = ffi.new('char *[1]')
        _raw.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]))
예제 #4
0
파일: kvs.py 프로젝트: cigolabs/flux-core
def KVSWatchWrapper(key, value, arg, errnum):
    (cb, real_arg) = ffi.from_handle(arg)
    ret = cb(ffi.string(key), json.loads(ffi.string(value)), real_arg, errnum)
    return ret if ret is not None else 0
예제 #5
0
파일: kvs.py 프로젝트: cigolabs/flux-core
 def __next__(self):
     ret = _raw.kvsitr_next(self.itr)
     if ret is None or ret == ffi.NULL:
         raise StopIteration()
     return ffi.string(ret)
예제 #6
0
파일: kvs.py 프로젝트: cigolabs/flux-core
 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
예제 #7
0
 def __next__(self):
     ret = _raw.kvsitr_next(self.itr)
     if ret is None or ret == ffi.NULL:
         raise StopIteration()
     return ffi.string(ret)
예제 #8
0
 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