more flaky fixes

This commit is contained in:
matlabbe
2026-05-27 23:00:53 -07:00
parent 0cd144069c
commit 1a841e8754
4 changed files with 20 additions and 2 deletions
+6
View File
@@ -97,6 +97,12 @@ void PyDescriptor::parseParameters(const ParametersMap & parameters)
_import_array();
// Invalidate importlib's directory-listing caches so a script created
// after sys.path was first scanned in this process is still found.
// Without this, the second Py* instance pointing at a freshly-written
// script in an already-known directory fails with ModuleNotFoundError.
PyRun_SimpleString("import importlib; importlib.invalidate_caches()");
std::string scriptName = uSplit(UFile::getName(path_), '.').front();
PyObject * pName = PyUnicode_FromString(scriptName.c_str());
UDEBUG("PyImport_Import() beg");
+6
View File
@@ -46,6 +46,12 @@ PyDetector::PyDetector(const ParametersMap & parameters) :
_import_array();
// Invalidate importlib's directory-listing caches so a script created
// after sys.path was first scanned in this process is still found. Without
// this, the second PyDetector instance pointing at a freshly-written
// script in an already-known directory fails with ModuleNotFoundError.
PyRun_SimpleString("import importlib; importlib.invalidate_caches()");
std::string scriptName = uSplit(UFile::getName(path_), '.').front();
PyObject * pName = PyUnicode_FromString(scriptName.c_str());
UDEBUG("PyImport_Import() beg");
+6
View File
@@ -53,6 +53,12 @@ PyMatcher::PyMatcher(
_import_array();
// Invalidate importlib's directory-listing caches so a script created
// after sys.path was first scanned in this process is still found.
// Without this, the second Py* instance pointing at a freshly-written
// script in an already-known directory fails with ModuleNotFoundError.
PyRun_SimpleString("import importlib; importlib.invalidate_caches()");
std::string scriptName = uSplit(UFile::getName(path_), '.').front();
PyObject * pName = PyUnicode_FromString(scriptName.c_str());
UDEBUG("PyImport_Import");