Pārlūkot izejas kodu

update 优化启动时间

18339543638 3 gadi atpakaļ
vecāks
revīzija
7accc5f164

+ 5 - 8
nb-service/web-service/src/main/java/com/nb/web/service/bus/hospital/script/PythonParse.java

@@ -25,14 +25,7 @@ public class PythonParse implements ScriptParse {
     private PyFunction pyFunction;
     private String script=null;
 
-    static {
-        //初始化python环境
-
-
-    }
-
     public PythonParse() {
-        PySystemState systemState = Py.getSystemState();
         Properties props = new Properties();
         props.setProperty("python.console.encoding", "UTF-8");
         props.put("python.home", "jython-standalone-2.7.1.jar");
@@ -41,8 +34,12 @@ public class PythonParse implements ScriptParse {
         props.put("python.import.site", "false");
         Properties preprops = System.getProperties();
         PythonInterpreter.initialize(preprops, props, new String[0]);
-        PythonInterpreter.initialize(System.getProperties(), props, new String[] {});
+        PySystemState systemState = Py.getSystemState();
+//        PyString standalone = new PyString("\\python-modules\\Lib");
+//        PyString xml = new PyString("E:\\software\\coffee-boot\\coffee-admin\\src\\main\\resources\\python");
+//        systemState.path.append(standalone);
         log.info("python path >>>>>>>>>>>>>>>>>:{}",systemState.path);
+        PythonInterpreter.initialize(System.getProperties(), props, new String[] {});
         interpreter = new PythonInterpreter();
 
     }