Преглед на файлове

Merge pull request #10636 from richardkchapman/python-preload

HPCC-18717 Python 3 embedded code may fail on imports

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday преди 7 години
родител
ревизия
8ad56cbce6
променени са 2 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. 1 1
      plugins/Rembed/Rembed.cpp
  2. 10 0
      plugins/py3embed/py3embed.cpp

+ 1 - 1
plugins/Rembed/Rembed.cpp

@@ -624,7 +624,7 @@ public:
     virtual void processBeginSet(const RtlFieldInfo * field, bool &isAll)
     {
         nextField(field);
-        isAll = false;  // No concept of an 'all' set in Python
+        isAll = false;  // No concept of an 'all' set in R
         Rcpp::List childrec = ::Rcpp::as<Rcpp::List>(elem);  // MORE - is converting it to a list inefficient? Keeps the code simpler!
         stack.append(*new ListState(childrec, field));
     }

+ 10 - 0
plugins/py3embed/py3embed.cpp

@@ -268,6 +268,16 @@ public:
             return;
         }
 #endif
+#ifndef _WIN32
+        // We need to ensure all symbols in the python3.x so are loaded - due to bugs in some distro's python installations
+        // However this will likely break python2.
+        // Therefore on systems where both are present, do NOT do this - people using centos systems that suffer from issue
+        // https://bugs.centos.org/view.php?id=6063 will need to choose which version of python plugin to install but not both
+
+        StringBuffer modname, py2modname;
+        if  (findLoadedModule(modname, "libpython3.") && !findLoadedModule(py2modname, "libpython2."))
+            pythonLibrary = dlopen(modname.str(), RTLD_NOW|RTLD_GLOBAL);
+#endif
         // Initialize the Python Interpreter
         Py_Initialize();
         const wchar_t *argv[] = { nullptr };