From 90f162ec3f63c45ba31d69e45c1ba27d98fdf830 Mon Sep 17 00:00:00 2001 From: Tomasz Wejroch Date: Fri, 24 Oct 2025 13:19:06 +0200 Subject: [PATCH] Removed uses of connector + refactor --- dbzero/dbzero/dbzero.pyi | 32 +++++--- dbzero/dbzero/interfaces.py | 5 +- python_tests/migration2_init.py | 7 +- python_tests/migration2_test.py | 7 +- python_tests/migration_init.py | 7 +- python_tests/migration_test_1.py | 7 +- python_tests/migration_test_2.py | 7 +- python_tests/test_connection.py | 15 ---- python_tests/test_init.py | 12 +-- src/dbzero/bindings/python/PyAPI.cpp | 84 +++++++++++--------- src/dbzero/bindings/python/PyAPI.hpp | 2 +- src/dbzero/bindings/python/PyInternalAPI.cpp | 8 +- src/dbzero/bindings/python/PyInternalAPI.hpp | 2 +- src/dbzero/bindings/python/PyWorkspace.cpp | 5 +- src/dbzero/bindings/python/dbzero.cpp | 2 +- src/dbzero/workspace/LockFlags.cpp | 2 +- src/dbzero/workspace/LockFlags.hpp | 2 +- 17 files changed, 101 insertions(+), 105 deletions(-) delete mode 100644 python_tests/test_connection.py diff --git a/dbzero/dbzero/dbzero.pyi b/dbzero/dbzero/dbzero.pyi index dc5b6ebd..2c5bc1a2 100644 --- a/dbzero/dbzero/dbzero.pyi +++ b/dbzero/dbzero/dbzero.pyi @@ -11,7 +11,7 @@ from .interfaces import ( # Core workspace management functions -def init(path: str, config: Optional[Dict[str, Any]] = None) -> None: +def init(path: str, config: Optional[Dict[str, Any]] = None, lock_flags: Optional[Dict[str, Any]] = None) -> None: """Initialize the dbzero environment in a specified directory and apply global configurations. This function sets up the underlying state management engine. @@ -29,8 +29,15 @@ def init(path: str, config: Optional[Dict[str, Any]] = None) -> None: * autocommit (bool, default True) to enable automatic commits * autocommit_interval (int, default 250) for commit interval in milliseconds - * cache_size (int, default 4 GiB) for main object cache size in bytes + * cache_size (int, default 2 GiB) for main object cache size in bytes * lang_cache_size (int, optional) for language model data cache size + lock_flags : dict, optional + Dictionary with configuration of locking behavior when opening the prefix in read-write mode. + + * blocking (bool, default False) to wait when trying to acquire the lock + * timeout (int) to set maximum waiting time in seconds when blocking wait is enabled + * force_unlock (bool, default False) to force unlocking of existing lock + Examples -------- @@ -66,6 +73,7 @@ def open(prefix_name: str, open_mode: str = "rw", **kwargs: Any) -> None: * autocommit (bool) to disable automatic commits for this prefix * slab_size (int) for memory slab allocation size in bytes * meta_io_step_size (int) for metadata I/O operation chunk size + * lock_flags (dict) to change locking behavior when opening the prefix for read-write Examples -------- @@ -148,7 +156,7 @@ def commit(prefix_name: Optional[str] = None) -> None: # Object retrieval and management -def fetch(id: Union[str, type], type: Optional[type] = None, prefix: Optional[str] = None) -> Memo: +def fetch(identifier: Union[str, type], expected_type: Optional[type] = None, prefix: Optional[str] = None) -> Memo: """Retrieve a single object directly from memory using its unique identifier. The fastest way to access an object, operating in constant time O(1). @@ -156,12 +164,12 @@ def fetch(id: Union[str, type], type: Optional[type] = None, prefix: Optional[st Parameters ---------- - id : str or type + identifier : str or type The identifier for the object you want to retrieve. * UUID string: Returns the specific object instance for that UUID * type (singleton class): Returns the unique instance of that singleton - type : type, optional + expected_type : type, optional Optional type to validate the retrieved object. Raises exception if the fetched object is not an instance of this type. prefix : str, optional @@ -202,7 +210,7 @@ def fetch(id: Union[str, type], type: Optional[type] = None, prefix: Optional[st """ ... -def exists(id: Union[str, type], type: Optional[type] = None, prefix: Optional[str] = None) -> bool: +def exists(identifier: Union[str, type], expected_type: Optional[type] = None, prefix: Optional[str] = None) -> bool: """Check if a dbzero object exists. Can check by UUID or by singleton type. @@ -210,12 +218,12 @@ def exists(id: Union[str, type], type: Optional[type] = None, prefix: Optional[s Parameters ---------- - id : str or type - The object to check for. + identifier : str or type + The identifier for object to check for. * str: Check for object with its unique identifier * type: Check for instance of this singleton type - type : type, optional + expected_type : type, optional Optional expected type when checking by UUID. Verifies the found object is an instance of this type. prefix : str, optional @@ -548,7 +556,7 @@ def touch(*objects: Memo) -> None: """ ... -def rename_field(class_obj: type, old_name: str, new_name: str) -> None: +def rename_field(class_obj: type, from_name: str, to_name: str) -> None: """Rename a field for a given Memo class. Modifies the internal field layout for all existing and future instances @@ -558,9 +566,9 @@ def rename_field(class_obj: type, old_name: str, new_name: str) -> None: ---------- class_obj : type The memo type for which to rename the field. - old_name : str + from_name : str The current name of the field you want to change. - new_name : str + to_name : str The new name for the field. Examples diff --git a/dbzero/dbzero/interfaces.py b/dbzero/dbzero/interfaces.py index 68bab78e..67dceb60 100644 --- a/dbzero/dbzero/interfaces.py +++ b/dbzero/dbzero/interfaces.py @@ -222,6 +222,7 @@ def find(self, *query_criteria: Union[Tag, List[Tag], Tuple[Tag], QueryObject, T QueryObject An iterable query object. """ + ... def deserialize(self, data: bytes, /) -> Any: """Reconstruct a dbzero object from serialized bytes, withing the snapshot context. @@ -236,6 +237,7 @@ def deserialize(self, data: bytes, /) -> Any: Any A dbzero object that was encoded in the data bytes. """ + ... def close(self) -> None: """Close dbzero snapshot.""" @@ -248,4 +250,5 @@ def get_state_num(self) -> int: ------- int State number of a snapshot. - """ \ No newline at end of file + """ + ... \ No newline at end of file diff --git a/python_tests/migration2_init.py b/python_tests/migration2_init.py index 6035700b..2be8d314 100644 --- a/python_tests/migration2_init.py +++ b/python_tests/migration2_init.py @@ -1,5 +1,4 @@ from dbzero import db0 -from dbzero.connection import Connection import os import datetime @@ -34,13 +33,13 @@ def __init__(self): def start(): # Configure the dbzero connection without connecting yet - Connection.setup(os.path.join(os.getcwd(), "app-data"), read_write=True, **config, client_app="migration-test") - Connection.assure_initialized() + db0.init(os.path.join(os.getcwd(), "app-data"), config=config) + db0.open(config["prefix"]) root = Root([]) for _ in range(10): root.value.append(MigrationTestClass()) - Connection.close() + db0.close() if __name__ == "__main__": diff --git a/python_tests/migration2_test.py b/python_tests/migration2_test.py index 86712136..ce97880a 100644 --- a/python_tests/migration2_test.py +++ b/python_tests/migration2_test.py @@ -1,5 +1,4 @@ from dbzero import db0 -from dbzero.connection import Connection import os import datetime @@ -36,8 +35,8 @@ def __init__(self): def start(): # Configure the dbzero connection without connecting yet - Connection.setup(os.path.join(os.getcwd(), "app-data"), read_write=True, **config, client_app="migration-test") - Connection.assure_initialized() + db0.init(os.path.join(os.getcwd(), "app-data"), config=config) + db0.open(config["prefix"]) root = Root() print(f"Root has: {len(root.value)} items") for _ in range(10): @@ -45,7 +44,7 @@ def start(): for item in root.value: print(f"Item date_value: {item.date_value}") - Connection.close() + db0.close() if __name__ == "__main__": diff --git a/python_tests/migration_init.py b/python_tests/migration_init.py index cdf925e2..b5bd5026 100644 --- a/python_tests/migration_init.py +++ b/python_tests/migration_init.py @@ -1,5 +1,4 @@ from dbzero import db0 -from dbzero.connection import Connection import os ORG_NAME = "division-by-zero" @@ -24,10 +23,10 @@ def __init__(self, value): def start(): # Configure the dbzero connection without connecting yet - Connection.setup(os.path.join(os.getcwd(), "app-data"), read_write=True, **config, client_app="migration-test") - Connection.assure_initialized() + db0.init(os.path.join(os.getcwd(), "app-data"), config=config) + db0.open(config["prefix"]) obj = MySingleton(123) - Connection.close() + db0.close() if __name__ == "__main__": diff --git a/python_tests/migration_test_1.py b/python_tests/migration_test_1.py index e7cbf6bb..239078df 100644 --- a/python_tests/migration_test_1.py +++ b/python_tests/migration_test_1.py @@ -1,5 +1,4 @@ from dbzero import db0 -from dbzero.connection import Connection import os ORG_NAME = "division-by-zero" @@ -34,14 +33,14 @@ def items(self): def start(): # Configure the dbzero connection without connecting yet - Connection.setup(os.path.join(os.getcwd(), "app-data"), read_write=True, **config, client_app="migration-test") - Connection.assure_initialized() + db0.init(os.path.join(os.getcwd(), "app-data"), config=config) + db0.open(config["prefix"]) obj = MySingleton(123) print(f"int param: {obj.int_param}") print(f"str param: {obj.str_param}") # note that migrated singleton should have 3 items print(list(obj.items)) - Connection.close() + db0.close() if __name__ == "__main__": diff --git a/python_tests/migration_test_2.py b/python_tests/migration_test_2.py index 9cde4ffa..584786ff 100644 --- a/python_tests/migration_test_2.py +++ b/python_tests/migration_test_2.py @@ -1,5 +1,4 @@ from dbzero import db0 -from dbzero.connection import Connection import os ORG_NAME = "division-by-zero" @@ -44,14 +43,14 @@ def str_items(self): def start(): # Configure the dbzero connection without connecting yet - Connection.setup(os.path.join(os.getcwd(), "app-data"), read_write=True, **config, client_app="migration-test") - Connection.assure_initialized() + db0.init(os.path.join(os.getcwd(), "app-data"), config=config) + db0.open(config["prefix"]) obj = MySingleton(123) print(f"int param: {obj.int_param}") print(f"str param: {obj.str_param}") print(list(obj.items)) print(dict(obj.str_items)) - Connection.close() + db0.close() if __name__ == "__main__": diff --git a/python_tests/test_connection.py b/python_tests/test_connection.py deleted file mode 100644 index 47b69645..00000000 --- a/python_tests/test_connection.py +++ /dev/null @@ -1,15 +0,0 @@ -import dbzero as db0 -import os -from .conftest import DB0_DIR - - -def test_default_prefix_after_connection_open(): - px_name = "some-test-prefix" - fname = px_name + ".db0" - if os.path.exists(fname): - os.remove(fname) - - db0.Connection.setup(read_write=True, client_app="app_name", prefix=px_name) - db0.Connection.assure_initialized() - assert db0.get_current_prefix().name == "some-test-prefix" - db0.Connection.close() \ No newline at end of file diff --git a/python_tests/test_init.py b/python_tests/test_init.py index 639694c3..60928a6c 100644 --- a/python_tests/test_init.py +++ b/python_tests/test_init.py @@ -4,11 +4,11 @@ import os -def test_lang_cache_size_can_be_specified_on_init(): - if os.path.exists(DB0_DIR): - shutil.rmtree(DB0_DIR) - os.mkdir(DB0_DIR) - db0.init(DB0_DIR, config={"lang_cache_size": 9876}) +def test_cache_size_can_be_specified_on_init(db0_fixture): + db0.close() + db0.init(DB0_DIR, config={"cache_size": 123456, "lang_cache_size": 9876}) db0.open("my-test-prefix") assert db0.get_lang_cache_stats()["capacity"] == 9876 - db0.close() + + stats = db0.get_cache_stats() + assert stats["capacity"] == 123456 diff --git a/src/dbzero/bindings/python/PyAPI.cpp b/src/dbzero/bindings/python/PyAPI.cpp index 534c55f4..170493ec 100644 --- a/src/dbzero/bindings/python/PyAPI.cpp +++ b/src/dbzero/bindings/python/PyAPI.cpp @@ -114,12 +114,11 @@ namespace db0::python return PyBool_fromBool(tryExistsIn(PyToolkit::getPyWorkspace().getWorkspace(), py_id, type, prefix_name)); } - bool tryParseFetchArgs(PyObject *, PyObject *args, PyObject *kwargs, PyObject *&py_id, + bool tryParseFetchArgs(PyObject *args, PyObject *kwargs, PyObject *&py_id, PyObject *&py_type, const char *&prefix_name) { - static const char *kwlist[] = { "id", "type", "prefix", NULL }; + static const char *kwlist[] = { "identifier", "expected_type", "prefix", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Os", const_cast(kwlist), &py_id, &py_type, &prefix_name)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return false; } @@ -140,7 +139,7 @@ namespace db0::python PyObject *py_id = nullptr; PyObject *py_type = nullptr; const char *prefix_name = nullptr; - if (!tryParseFetchArgs(nullptr, args, kwargs, py_id, py_type, prefix_name)) { + if (!tryParseFetchArgs(args, kwargs, py_id, py_type, prefix_name)) { // error already set in tryParseFetchArgs return NULL; } @@ -155,7 +154,7 @@ namespace db0::python PyObject *py_type = nullptr; const char *prefix_name = nullptr; // takes same arguments as fetch - if (!tryParseFetchArgs(nullptr, args, kwargs, py_id, py_type, prefix_name)) { + if (!tryParseFetchArgs(args, kwargs, py_id, py_type, prefix_name)) { // error already set in tryParseFetchArgs return NULL; } @@ -176,10 +175,9 @@ namespace db0::python PyObject *py_slab_size = nullptr; PyObject *py_lock_flags = nullptr; PyObject *py_meta_io_step_size = nullptr; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|sOOOO", const_cast(kwlist), + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|sOOOO:open", const_cast(kwlist), &prefix_name, &open_mode, &py_autocommit, &py_slab_size, &py_lock_flags, &py_meta_io_step_size)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -237,11 +235,10 @@ namespace db0::python { PyObject *py_path = nullptr; PyObject *py_config = nullptr; - PyObject *py_flags= nullptr; + PyObject *py_flags = nullptr; // extract optional "path" string argument and "autcommit_interval" keyword argument static const char *kwlist[] = {"path", "config", "lock_flags", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO", const_cast(kwlist), &py_path, &py_config, &py_flags)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO:init", const_cast(kwlist), &py_path, &py_config, &py_flags)) { return NULL; } @@ -260,40 +257,50 @@ namespace db0::python return NULL; } - // py_config must be a dict + // py_flags must be a dict if (py_flags && !PyDict_Check(py_flags)) { PyErr_SetString(PyExc_TypeError, "Invalid argument type: flags"); return NULL; } - using ObjectSharedPtr = PyTypes::ObjectSharedPtr; - ObjectSharedPtr config_obj; - if (py_config) { - config_obj = Py_OWN(PyDict_Copy(py_config)); - } - else { - config_obj = Py_OWN(PyDict_New()); - } + auto config_obj = Py_OWN(PyDict_New()); if (!config_obj) { return nullptr; } using DefaultValueFunction = PyObject*(*)(); const std::pair defaults[] = { + {"cache_size", []{ return PyLong_FromLong(BaseWorkspace::DEFAULT_CACHE_SIZE); }}, + {"lang_cache_size", []{ return PyLong_FromLong(LangCache::DEFAULT_CAPACITY); }}, {"autocommit", []{ Py_RETURN_TRUE; }}, {"autocommit_interval", []{ return PyLong_FromLong(Workspace::DEFAULT_AUTOCOMMIT_INTERVAL_MS); }} }; - for (const auto &[key, value_function] : defaults) { + for (const auto &[key_str, default_fn] : defaults) { // Populate default values so then can be easily accessed with get_config - auto key_obj = Py_OWN(PyUnicode_FromString(key)); + auto key = Py_OWN(PyUnicode_FromString(key_str)); if (!key) { return nullptr; } - auto value_obj = Py_OWN(value_function()); - if (!value_obj) { + + int contains = 0; + if(py_config) { + contains = PyDict_Contains(py_config, *key); + if (contains == -1) { + return nullptr; + } + } + PyTypes::ObjectSharedPtr config_value; + if (contains) { + config_value = Py_BORROW(PyDict_GetItemWithError(py_config, *key)); + } + else { + config_value = Py_OWN(default_fn()); + } + if(!config_value) { return nullptr; } - if (!PySafeDict_SetDefault(*config_obj, key_obj, value_obj)) { + + if(PyDict_SetItem(*config_obj, *key, *config_value)) { return nullptr; } } @@ -332,8 +339,7 @@ namespace db0::python { // extract optional prefix name const char *prefix_name = nullptr; - if (!PyArg_ParseTuple(args, "|s", &prefix_name)) { - PyErr_SetString(PyExc_TypeError, "Invalid argument type"); + if (!PyArg_ParseTuple(args, "|s:commit", &prefix_name)) { return NULL; } @@ -381,8 +387,7 @@ namespace db0::python { // extract optional prefix name const char *prefix_name = nullptr; - if (!PyArg_ParseTuple(args, "|s", &prefix_name)) { - PyErr_SetString(PyExc_TypeError, "Invalid argument type"); + if (!PyArg_ParseTuple(args, "|s:close", &prefix_name)) { return NULL; } @@ -509,7 +514,7 @@ namespace db0::python const char *prefix_name = nullptr; int finalized = 0; const char * const kwlist[] = {"prefix", "finalized", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|sp", const_cast(kwlist), &prefix_name, &finalized)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|sp:get_state_num", const_cast(kwlist), &prefix_name, &finalized)) { return nullptr; } @@ -558,15 +563,16 @@ namespace db0::python return runSafe(tryDescribeObject, self, args); } - PyObject *tryRenameField(PyObject *args) + PyObject *tryRenameField(PyObject *args, PyObject *kwargs) { // extract 3 required arguments: class, from name, to name PyTypeObject *py_type; const char *from_name = nullptr; const char *to_name = nullptr; - if (!PyArg_ParseTuple(args, "Oss", &py_type, &from_name, &to_name)) { - PyErr_SetString(PyExc_TypeError, "Invalid argument type"); - return NULL; + + const char * const kwlist[] = {"class_obj", "from_name", "to_name", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oss:rename_field", const_cast(kwlist), &py_type, &from_name, &to_name)) { + return nullptr; } // check if py type @@ -575,14 +581,14 @@ namespace db0::python return nullptr; } - renameField(py_type, from_name, to_name); + renameMemoClassField(py_type, from_name, to_name); Py_RETURN_NONE; } - PyObject *renameField(PyObject *, PyObject *args) + PyObject *renameField(PyObject *, PyObject *args, PyObject *kwargs) { PY_API_FUNC - return runSafe(tryRenameField, args); + return runSafe(tryRenameField, args, kwargs); } PyObject *TryPyAPI_isSingleton(PyObject *py_object) @@ -753,8 +759,10 @@ namespace db0::python // extract filter callable and query objects PyObject *py_filter = nullptr; PyObject *py_query = nullptr; - if (!PyArg_ParseTuple(args, "OO", &py_filter, &py_query)) { - THROWF(db0::InputException) << "Invalid argument type"; + + const char * const kwlist[] = {"prefix", "finalized", nullptr}; + if(!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:filter", const_cast(kwlist), &py_filter, &py_query)) { + return nullptr; } // py_filter must be a python callable diff --git a/src/dbzero/bindings/python/PyAPI.hpp b/src/dbzero/bindings/python/PyAPI.hpp index e7198f78..de10d874 100644 --- a/src/dbzero/bindings/python/PyAPI.hpp +++ b/src/dbzero/bindings/python/PyAPI.hpp @@ -101,7 +101,7 @@ namespace db0::python */ PyObject *describeObject(PyObject *self, PyObject *args); - PyObject *renameField(PyObject *self, PyObject *args); + PyObject *renameField(PyObject *self, PyObject *args, PyObject *kwargs); PyObject *PyAPI_isSingleton(PyObject *self, PyObject *args); diff --git a/src/dbzero/bindings/python/PyInternalAPI.cpp b/src/dbzero/bindings/python/PyInternalAPI.cpp index 60a80454..5ee3cc5b 100644 --- a/src/dbzero/bindings/python/PyInternalAPI.cpp +++ b/src/dbzero/bindings/python/PyInternalAPI.cpp @@ -273,7 +273,7 @@ namespace db0::python } - PyObject* tryRenameField(PyTypeObject *py_type, const char *from_name, const char *to_name) + void renameMemoClassField(PyTypeObject *py_type, const char *from_name, const char *to_name) { using ClassFactory = db0::object_model::ClassFactory; auto fixture_uuid = MemoTypeDecoration::get(py_type).getFixtureUUID(); @@ -287,12 +287,6 @@ namespace db0::python // resolve existing DB0 type from python type auto type = class_factory.getExistingType(py_type); type->renameField(from_name, to_name); - Py_RETURN_NONE; - } - - PyObject *renameField(PyTypeObject *py_type, const char *from_name, const char *to_name){ - PY_API_FUNC - return runSafe(tryRenameField, py_type, from_name, to_name); } diff --git a/src/dbzero/bindings/python/PyInternalAPI.hpp b/src/dbzero/bindings/python/PyInternalAPI.hpp index f09d7466..b338ec84 100644 --- a/src/dbzero/bindings/python/PyInternalAPI.hpp +++ b/src/dbzero/bindings/python/PyInternalAPI.hpp @@ -83,7 +83,7 @@ namespace db0::python bool isExistingObject(db0::swine_ptr &fixture, ObjectId object_id, PyTypeObject *py_expected_type = nullptr); - PyObject *renameField(PyTypeObject *py_type, const char *from_name, const char *to_name); + void renameMemoClassField(PyTypeObject *py_type, const char *from_name, const char *to_name); /** * Runs a function, catch exeptions and translate into Python errors diff --git a/src/dbzero/bindings/python/PyWorkspace.cpp b/src/dbzero/bindings/python/PyWorkspace.cpp index aed5c60e..2f4b33e2 100644 --- a/src/dbzero/bindings/python/PyWorkspace.cpp +++ b/src/dbzero/bindings/python/PyWorkspace.cpp @@ -56,8 +56,11 @@ namespace db0::python m_config = std::make_shared(py_config); db0::Config default_lock_flags(py_lock_flags); + // Retrieve the cache size from passed config parameters + auto cache_size = m_config->get("cache_size"); + m_workspace = std::shared_ptr( - new Workspace(root_path, {}, {}, {}, {}, db0::object_model::initializer(), m_config, default_lock_flags)); + new Workspace(root_path, std::move(cache_size), {}, {}, {}, db0::object_model::initializer(), m_config, default_lock_flags)); // register a callback to register bindings between known memo types (language specific objects) // and the corresponding Class instances. Note that types may be prefix agnostic therefore bindings may or diff --git a/src/dbzero/bindings/python/dbzero.cpp b/src/dbzero/bindings/python/dbzero.cpp index 9d2360dc..a4b01b0b 100644 --- a/src/dbzero/bindings/python/dbzero.cpp +++ b/src/dbzero/bindings/python/dbzero.cpp @@ -59,7 +59,7 @@ static PyMethodDef dbzero_methods[] = {"begin_atomic", (PyCFunction)&py::PyAPI_beginAtomic, METH_FASTCALL, "Opens a new atomic operation's context"}, {"begin_locked", (PyCFunction)&py::PyAPI_beginLocked, METH_FASTCALL, "Enter a new locked section"}, {"describe", &py::describeObject, METH_VARARGS, "Get dbzero object's description"}, - {"rename_field", &py::renameField, METH_VARARGS, "Get snapshot of dbzero state"}, + {"rename_field", (PyCFunction)&py::renameField, METH_VARARGS | METH_KEYWORDS, "Get snapshot of dbzero state"}, {"is_singleton", &py::PyAPI_isSingleton, METH_VARARGS, "Check if a specific instance is a dbzero singleton"}, {"getrefcount", &py::PyAPI_getRefCount, METH_VARARGS, "Get dbzero ref counts"}, {"no", (PyCFunction)&py::negTagSet, METH_FASTCALL, "Tag negation function"}, diff --git a/src/dbzero/workspace/LockFlags.cpp b/src/dbzero/workspace/LockFlags.cpp index 51a96dc8..c49a02d2 100644 --- a/src/dbzero/workspace/LockFlags.cpp +++ b/src/dbzero/workspace/LockFlags.cpp @@ -3,7 +3,7 @@ db0::LockFlags::LockFlags(Config py_logs_flags) { - m_blocking = py_logs_flags.get("blocking", true); + m_blocking = py_logs_flags.get("blocking", false); m_timeout = py_logs_flags.get("timeout", 0); m_relock_on_removed_lock = py_logs_flags.get("relock_on_removed_lock", false); m_force_unlock = py_logs_flags.get("force_unlock", false); diff --git a/src/dbzero/workspace/LockFlags.hpp b/src/dbzero/workspace/LockFlags.hpp index 6ba7100d..d0c801a3 100644 --- a/src/dbzero/workspace/LockFlags.hpp +++ b/src/dbzero/workspace/LockFlags.hpp @@ -15,7 +15,7 @@ namespace db0 LockFlags(bool no_lock); - bool m_blocking = true; + bool m_blocking = false; int m_timeout = 0; bool m_relock_on_removed_lock = false; bool m_force_unlock = false;