def create_kvdb(): kvdb_home = config.KVDB_HOME kvs_name = config.KVS_NAME hse.init() try: try: hse.Kvdb.create(kvdb_home) except hse.HseException as e: if e.returncode == errno.EEXIST: hse.Kvdb.drop(kvdb_home) hse.Kvdb.create(kvdb_home) else: raise e kvdb = hse.Kvdb.open(kvdb_home) try: kvdb.kvs_create(kvs_name) finally: kvdb.close() finally: hse.fini()
from utility import lifecycle hse.init() try: with ExitStack() as stack: kvdb_ctx = lifecycle.KvdbContext() kvdb = stack.enter_context(kvdb_ctx) kvs_ctx = lifecycle.KvsContext(kvdb, "bug_wrong_view_value") kvs = stack.enter_context(kvs_ctx) kvs.put(b"a", b"1") kvs.put(b"b", b"2") with kvs.cursor() as cur: # replace a, outside of view of cursor kvs.put(b"a", b"3") kv = cur.read() assert kv == (b"a", b"1") cur.read() cur.read() cur.update_view() cur.seek(b"a") kv = cur.read() assert kv == (b"a", b"3") finally: hse.fini()