Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions dbzero/dbzero/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


@overload
def enum(cls: str, values: List[str], *, prefix: Optional[str] = None) -> EnumType: ...
def enum(cls: str, values: List[str]) -> EnumType: ...

@overload
def enum(*, values: List[str], prefix: Optional[str] = None) -> EnumType: ...
def enum(*, values: List[str]) -> EnumType: ...

@overload
def enum(cls: type) -> EnumType: ...
Expand All @@ -30,10 +30,6 @@ def enum(cls: Optional[Union[str, type]] = None, *args: Any, **kwargs: Any) -> E
values : list of str
A list of unique string names for the enum members. The order of values
is preserved.
prefix : str, optional
Scopes the enum definition to a specific data prefix. If None (default),
the enum is defined in the prefix that is active at the time of creation.
This allows for creating data-model-specific enums.

Returns
-------
Expand Down
7 changes: 6 additions & 1 deletion src/dbzero/bindings/python/Memo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ namespace db0::python
PY_API_FUNC
// destroy associated db0 Object instance
memo_obj->destroy();
Py_TYPE(memo_obj)->tp_free((PyObject*)memo_obj);
if (Py_IsInitialized())
{
// Skip deallocation during/after Python finalization
// Python Garbage Collector might be finalized (i.e. destroyed) at this point
Py_TYPE(memo_obj)->tp_free((PyObject*)memo_obj);
}
}

template <typename MemoImplT>
Expand Down
6 changes: 6 additions & 0 deletions src/dbzero/bindings/python/PyToolkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,12 @@ namespace db0::python
return {};
}

if (!Py_IsInitialized()) {
// Simply return the lock after python instance was finalized
// This is safe because fixture threads should be stopped at this point
return SafeRLock(m_api_mutex);
}

// unlock GIL while waiting for the API mutex
PyThreadState *__save = PyEval_SaveThread();
auto result = SafeRLock(m_api_mutex);
Expand Down
6 changes: 4 additions & 2 deletions src/dbzero/object_model/value/Member.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ namespace db0::object_model
{
// create member function pointer
using UnloadMemberFunc = typename LangToolkit::ObjectSharedPtr (*)(db0::swine_ptr<Fixture> &, Value, unsigned int, AccessFlags);
static std::vector<UnloadMemberFunc> unload_member_functions;
static auto *unload_member_functions_ptr = new std::vector<UnloadMemberFunc>();
auto &unload_member_functions = *unload_member_functions_ptr;
if (unload_member_functions.empty()) {
registerUnloadMemberFunctions<LangToolkit>(unload_member_functions);
}
Expand All @@ -101,7 +102,8 @@ namespace db0::object_model
{
// create member function pointer
using UnrefMemberFunc = void (*)(db0::swine_ptr<Fixture> &, Value);
static std::vector<UnrefMemberFunc> unref_member_functions;
static auto *unref_member_functions_ptr = new std::vector<UnrefMemberFunc>();
auto &unref_member_functions = *unref_member_functions_ptr;
if (unref_member_functions.empty()) {
registerUnrefMemberFunctions<LangToolkit>(unref_member_functions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/workspace/FixtureThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace db0
// otherwise it may deadlock on trying to invoke API calls from auto-commit
// (e.g. instance destruction triggered by LangCache::clear)
auto __api_lock = LangToolkit::lockApi();
// // NOTE: since this a separate thread, we must acuire the language interpreter's lock (where required)
// NOTE: since this a separate thread, we must acquire the language interpreter's lock (where required)
auto lang_lock = LangToolkit::ensureLocked();
auto callbacks = fixture.onAutoCommit();
if (!callbacks.empty()) {
Expand Down