Package jep

Class SharedInterpreter

java.lang.Object
jep.Jep
jep.SharedInterpreter
All Implemented Interfaces:
AutoCloseable, Interpreter

public class SharedInterpreter extends Jep
Class for creating instances of Interpreters which share all imported modules. In this case each SharedInterpreter still maintains distinct global variables but some interpreter state will be shared. This is equivalent to using shared modules to share every Python package in Jep. Anything that changes the way a module behaves will impact all SharedInterpreters so care must be taken to ensure that different SharedInterpreters aren't conflicting. For example sys.path, time.tzset(), and numpy.seterr() will change the behavior of all SharedInterpreters. Within a single Java process it is valid to mix Interpreter instances that use SubInterpreters with SharedInterpreters. The SubInterpreter instances will remain isolated from SubInterpreter instances and from any SharedInterpreters. To maintain stability, it is not possible to have multiple Interpreter instances active on the same Thread at the same time and this limitation includes SharedInterpreters.
Since:
3.8
  • Constructor Details

  • Method Details

    • setConfig

      public static void setConfig(JepConfig config) throws JepException
      Sets interpreter settings for the all SharedInterpreters. This method must be called before the first SharedInterpreter is created in the process.
      Parameters:
      config - the jep configuration to use.
      Throws:
      JepException - if an error occurs
      Since:
      3.9