I am using a Python ScriptEngine in my Java application to execute a Python script that imports various other Python scripts.
Once the main script successfully completes and the eval method returns, I set the engine object reference to null and call the garbage collector.
Next I go and edit one of the scripts that was imported by the main script and save it.
Next I run the method to execute the main Python script as before by creating a new ScriptEngine object and calling eval, but when the main script runs it does not pick up the changes to the imported script that I made.
Obviously the imported scripts are being cached somewhere by something (maybe Jython?).
I do not want to call reload in the Python script. There must be a way to tell whatever is doing the caching to flush or clear itself.
Anyone found a solution to this problem? I am using NetBeans 8.0.2, Java 1.8 update 45, and Jython 2.7 on Windows 7. Here is the java code. It doesn't really matter what the python script contains other than import statements.
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine engine = scriptEngineManager.getEngineByName("python");
Object result = engine.eval();
engine = null;
System.gc();