Thanks for the pointer Ben, I managed to get this working using sys.path += as you do in the Jep Source.
I have a slightly stranger issue now. Our system allows users to write plugins in python and we use Jep to call the python function in java.
We allow the user to modiy their code and re-calculate on the fly.
To do this When I was using the standard Jep instances I would check the file modified time and if it had been updated since the last calculation I would use a new Jep instance to force the 'plugin' module to be re-loaded.
When switching to SharedInterpreter, creating a new SharedInterpreter does not way in the same way as the state is shared among all SharedInterpreters.
final boolean modified = checkModifiedTime();
jep.eval("import " + getLibName());
if (modified)
{
jep.eval("import importlib");
jep.eval("importlib.reload(" + getLibName() + ")");
}
Where jep is a SharedInterpreter and getLibName() returns the plugin module.
When I do this though I get random errors where sys.stdout gets lost:
jep.JepException: <class 'RuntimeError'>: lost sys.stdout
I do have classes in my module that are abstract base classes and use the abc module. I found online that if you have your own module called abc.py then you get this message also.
If I comment out the if (modified) block so it doesn't reload the module and re-run the application, I don't get this error. I did notice that importlib has an abc sub module (importlib.abc) and wondered if the two modules were clashing somehow.
I tried importing the builtin abc as an alias, importing via from abc import ABC, abstractmethod but to no avail.
The biggest issue is that I can't seem to reproduce this in a cut down example to post here. I have tried to replicate as much as possible from the live system (using abc, having an abstract class with a couple of implementations, using shared interpreter and using importlib.reload).
Is there any other way I could "reload" a module when using a shared interpreter?
I am convinced it is something to do with using importlib.reload but I don't know why this works fine in the cut-down example.
Regards,
Mike