From 667764b3dfb228a63cc14bdd5b2636b1780d2845 Mon Sep 17 00:00:00 2001 From: Matevz Morato Date: Mon, 6 May 2024 13:13:31 +0200 Subject: [PATCH] Import threading to avoid an error on exit --- bindings/python/src/py_bindings.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bindings/python/src/py_bindings.cpp b/bindings/python/src/py_bindings.cpp index 4b59d37c0..189c48d13 100644 --- a/bindings/python/src/py_bindings.cpp +++ b/bindings/python/src/py_bindings.cpp @@ -119,6 +119,11 @@ PYBIND11_MODULE(depthai, m) // Read the uintptr_t value from the decimal string sscanf(javavmEnvStr.c_str(), "%" SCNuPTR, reinterpret_cast(&javavm)); + // Import threading module - TODO(Morato) explore why this is needed to avoid the exception + // Relevant issue: https://github.com/pybind/pybind11/issues/2197 + // It should be harmless to import it here, as it is a built-in module + py::object threading = py::module_::import("threading"); + // Call dai::initialize on 'import depthai' to initialize asap with additional information to print try { dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler, javavm);